The Quintessential Swing User Interface

This example creates and shows a frame with a button. To enable the button to respond to button clicks, see Creating a JButton Component.
import java.awt.*; import javax.swing.*; public class BasicUI { public static void main(String[] args) { JButton button = new JButton("Label"); JFrame frame = new JFrame(); // Add button to the frame frame.getContentPane().add(button, BorderLayout.CENTER); // Set initial size int frameWidth = 300; int frameHeight = 300; frame.setSize(frameWidth, frameHeight); // Show the frame frame.setVisible(true); } }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.