Skip to content

Commit

Permalink
HotFix: 界面优化 (#41)
Browse files Browse the repository at this point in the history
* 界面优化

* 清空输入框

* 排版

* hotfix: 越界、定期时间

* hotfix:金额刷新
  • Loading branch information
Qianmoxsn authored May 26, 2024
1 parent ec9263b commit 55ca537
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 86 deletions.
11 changes: 8 additions & 3 deletions src/main/java/com/seg83/childbank/gui/component/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.seg83.childbank.gui.component.welcome.SetupPanel;
import com.seg83.childbank.gui.component.welcome.WelcomePanel;
import com.seg83.childbank.gui.event.PanelSwitchEvent;
import com.seg83.childbank.service.DepositService;
import com.seg83.childbank.service.InterestService;
import com.seg83.childbank.service.SetupService;
import jakarta.annotation.PostConstruct;
Expand All @@ -32,18 +33,19 @@ public class MainFrame extends JFrame {

private SetupService setupService;
private InterestService interestService;
private DepositService depositService;

public MainFrame() throws HeadlessException {
setTitle("ChildBank");
setSize(600, 400);
setSize(700, 500);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
log.info("Create MainFrame");
}

@Autowired
private void setPanels(HomePanel homePanel, WelcomePanel welcomePanel, SetupPanel setupPanel, SetupService setupService, InterestService interestService,
SettingsPanel settingsPanel, FixedAccountPanel fixedAccountPanel, CurrentAccountPanel currentAccountPanel, TaskPanel taskPanel) {
SettingsPanel settingsPanel, FixedAccountPanel fixedAccountPanel, CurrentAccountPanel currentAccountPanel, TaskPanel taskPanel, DepositService depositService) {
this.homePanel = homePanel;
this.welcomePanel = welcomePanel;
this.setupPanel = setupPanel;
Expand All @@ -53,6 +55,7 @@ private void setPanels(HomePanel homePanel, WelcomePanel welcomePanel, SetupPane
this.fixedAccountPanel = fixedAccountPanel;
this.currentAccountPanel = currentAccountPanel;
this.taskPanel = taskPanel;
this.depositService = depositService;
}

@PostConstruct
Expand Down Expand Up @@ -98,6 +101,7 @@ private void initSetupPanel() {
private void initHomePanel() {
homePanel.$$$getRootComponent$$$().updateUI();
interestService.calculateCurrentInterest();
depositService.processMaturedDeposits();
homePanel.updateCurrentBallance();
homePanel.updateGoal();
homePanel.updateFixBallance();
Expand All @@ -120,6 +124,7 @@ private void initSettingsPanel() {

private void initFixedAccountPanel() {
fixedAccountPanel.createTable();
fixedAccountPanel.setTotalFixedLabel();
fixedAccountPanel.$$$getRootComponent$$$().updateUI();
setContentPane(this.fixedAccountPanel.$$$getRootComponent$$$());
// 显式刷新
Expand All @@ -137,7 +142,7 @@ private void initCurrentPanel() {
repaint();
log.info("Create currentAccountPanel in MainFrame");
}

private void initTaskPanel() {
taskPanel.createTable();
taskPanel.$$$getRootComponent$$$().updateUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ private void onCancel() {

public void init() {
log.debug("Initializing rate setting dialog");
// Clear the text fields
textField1.setText("");
passwordField1.setText("");
this.pack(); // 使用已经存在的this引用而不是创建新的实例
setLocationRelativeTo(null); // null 使窗口居中于屏幕
this.setVisible(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void onOK() {
String month = monthField.getText();
int monthInt;
try {
monthInt = Integer.parseInt(amount);
monthInt = Integer.parseInt(month);
} catch (NumberFormatException e) {
// show a dialog
JOptionPane.showMessageDialog(this, "Amount should be an Integer", "Error", JOptionPane.ERROR_MESSAGE);
Expand Down Expand Up @@ -127,8 +127,12 @@ private void onOK() {
if (!check) {
JOptionPane.showMessageDialog(this, "Password mistake", "Error", JOptionPane.ERROR_MESSAGE);
} else {
depositService.depositFixAccount(amountInt, rateDouble, todayStr, futureDateStr);
dispose();
if (depositService.depositFixAccount(amountInt, rateDouble, todayStr, futureDateStr)) {
dispose();
} else {
JOptionPane.showMessageDialog(this, "Deposit failed", "Error", JOptionPane.ERROR_MESSAGE);
}

}
}

Expand All @@ -141,6 +145,10 @@ private void onCancel() {

public void init() {
log.debug("Initializing tofix dialog");
// Clear the text fields
amountField.setText("");
monthField.setText("");
passwordField1.setText("");
this.pack(); // 使用已经存在的this引用而不是创建新的实例
setLocationRelativeTo(null); // null 使窗口居中于屏幕
this.setVisible(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,13 @@ public class FixedAccountPanel {
private JTable table1;
private JLabel totalLabel;


public FixedAccountPanel() {
// $$$setupUI$$$();
backButton.addActionListener(e -> {
publisher.publishEvent(new PanelSwitchEvent(this, "home"));
});
}

@PostConstruct
public void init() {
setTotalFixedLabel();
}

public void createTable() {
// TODO: use actual data
Expand All @@ -72,9 +67,8 @@ public void createTable() {
columnModel.getColumn(4).setPreferredWidth(200); // Expire Date 列
}


public void setTotalFixedLabel() {
totalLabel.setText(String.valueOf(depositService.calculateTotalDeposits()));
totalLabel.setText("$" + depositService.calculateTotalDeposits());
}

{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<properties/>
<border type="none" title="HomePage"/>
<children>
<grid id="1782" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<grid id="1782" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="1" left="1" bottom="1" right="1"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
Expand All @@ -18,12 +18,50 @@
<children>
<component id="4100" class="javax.swing.JLabel" binding="displayGoal">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="2" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="7"/>
</grid>
</constraints>
<properties>
<text value="$1734/$2000"/>
</properties>
</component>
<grid id="a5db3" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="8216" class="javax.swing.JProgressBar" binding="progressBar">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="1645c" class="javax.swing.JLabel" binding="progressText">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="114%"/>
</properties>
</component>
</children>
</grid>
<vspacer id="fd463">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="5"/>
</grid>
</constraints>
</vspacer>
<vspacer id="11169">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
<grid id="65917" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
Expand Down
Loading

0 comments on commit 55ca537

Please sign in to comment.