![]() |
This is about the simplest GUI (Graphical User Interface) window that you can make. The window is very small, and will appear in the top left corner of the screen, so you may not see it at first. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
//--- basic_windows/FirstWindow.java - Creates a very small window!
// This is just about the smallest GUI program you can write.
// It does nothing, but you can see that the close box works
// and the window can be resized.
// Fred Swartz 2004-10-26
import javax.swing.*;
////////////////////////////////////////////////////// class FirstWindow
class FirstWindow {
// ===================================================== method main
public static void main(String[] args) {
JFrame window = new JFrame("My First Window");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
}
}
|
import statement specifies library classes that are needed.
This statement imports all classes from the javax.swing
package, altho only the JFrame class is used.
JFrame is the Java class for