Skip to content

Commit 0700431

Browse files
committed
Added an exit button for accommodating the fact that the close button is too far to reach
1 parent cd84977 commit 0700431

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/MainFrame.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public class MainFrame extends JFrame implements ActionListener {
2020
JTextField xTextField;
2121
JTextField yTextField;
2222
JCheckBox resizable;
23+
2324
JButton resizeButton;
25+
JButton exitButton;
2426

2527
int xSize;
2628
int ySize;
@@ -78,11 +80,15 @@ public MainFrame() {
7880
this.add(buttonPanel);
7981

8082
resizeButton = new JButton("Resize");
81-
resizeButton.setPreferredSize(new Dimension(72, 26));
8283
resizeButton.setFocusable(false);
8384
resizeButton.addActionListener(this);
8485
buttonPanel.add(resizeButton);
8586

87+
exitButton = new JButton("Exit");
88+
exitButton.setFocusable(false);
89+
exitButton.addActionListener(this);
90+
buttonPanel.add(exitButton);
91+
8692
this.setTitle("Textfield resizes window");
8793
this.setSize(minWidth, minHeight);
8894
this.setMinimumSize(this.getSize());
@@ -110,6 +116,8 @@ public void actionPerformed(ActionEvent e) {
110116
}
111117
} else if (e.getSource() == resizable) {
112118
this.setResizable(!this.isResizable());
119+
} else if (e.getSource() == exitButton) {
120+
System.exit(0);
113121
}
114122
}
115123
}

0 commit comments

Comments
 (0)