How to create a simple window with Java
This example shows how to create a simple window with Java, set the size and makes it visible:
import javax.swing.*;
public class GUITest
{
public static void main(String[] args)
{
// Create the frame
JFrame jframeTest = new JFrame();
// Set the title of the JFrame
jframeTest.setTitle("GUITest");
// Set the size of the JFrame (widht, height)
jframeTest.setSize(400,300);
jframeTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframeTest.setVisible(true);
}
}
Category: Java