SimpleButton1

Main.java  [download]

/*
 * Simple button program
 */

import java.awt.Container; //*1 Import the classes you need
import javax.swing.JFrame; //*1

public class Main extends JFrame { //*2 Subclass JFrame
    public static void main (String [] args) {
	new Main (); //*3 Put code in constructor not main()
    }
    
    public Main () { //*3
	// Window setup
	setSize (300, 300);
	Container content = getContentPane();

	// Put a button in
	MyButton b1 = new MyButton ("Push me"); //*4 Create a widget
	content.add (b1); //*5 Add widget to window

	// Show the window
	setVisible (true); //*6 Map window to screen
    }
}

MyButton.java  [download]

import javax.swing.JButton;

public class MyButton extends JButton { //*1 Will want separate class in future
    public MyButton (String label) {
	setText (label); //*2 (is public method, could have called from parent)
    }
}