JFrame. (There is also an AWT Frame class, the parent class of JFrame).
A GUI program (usually) consists of (i) a GUI interface, (ii) listener methods, and (iii) application code. Our first GUI program does not have a listener nor any application code, and is not a useful program. But it will get us started. Here is the complete program:
import java.awt.*; import javax.swing.*; public class TestFrame1 { public static void main ( String[] args ) { JFrame frame = new JFrame("Test Frame 1"); frame.setSize(200,100); frame.setVisible( true ); } }
The setSize()
method makes the rectangular area
200 pixels wide by 100 pixels high.
The setVisible()
method makes the frame appear
on the screen (otherwise the frame object exists as an object in memory,
but there is no picture for it).