File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments