![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e732. The Quintessential Swing User InterfaceThis example creates and shows a frame with a button. To enable the button to respond to button clicks, see e743 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); } }
© 2002 Addison-Wesley. |