University of Technology, Jamaica School of Computing and Information Technology Advanced Programming (CIT3009)
University of Technology, Jamaica School of Computing and Information Technology Advanced Programming (CIT3009)
Objectives:
✔ To give students a better understanding of working with the javax.swing
✔ To allow students to practice working with GUI components in the javax.swing package
Exercise One
11. Now that the button has been added to the frame, make the frame visible with the
following line of code;
frame.setVisible(true);
12. In the main method create a new instance of the GUIDemo class:
new GUIDemo();
14. Now close the window with the close icon ‘X’ at the top right hand corner of the
window.
15. In the are of your console you should be seeing something similar to the following
image
The red square is an indication that your program is still running even though you have
closed the window. To fix that add the following line of code to yor frame configuration:
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16. Run the program again and note the difference when you close the window