package swingExamples; // ButtonExample1 // JFrame with one button import javax.swing.JFrame; import javax.swing.JButton; public class ButtonExample1 { private JFrame frame; private JButton button1; public ButtonExample1( ) { // create JFrame with title as in JFrame1.java frame = new JFrame( "Button Examle 1"); frame.setSize( 300, 300); frame.setLocation( 200, 200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // create and add a button to the frame button1 = new JButton("This is Button 1"); frame.add( button1 ); } public void launch ( ) { frame.setVisible( true ); } /** * @param args */ public static void main(String[] args) { ButtonExample1 buttonEx1 = new ButtonExample1( ); buttonEx1.launch(); } }