This is a basic JFrame with a basic JButton.
Code:import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; /* * Main.java * Basic JFrame with a basic JButton. * Created by: Joey * July 18, 2008 */ public class Main extends JFrame implements ActionListener{ /** * */ private static final long serialVersionUID = 1L; public Main(){ /* * JFrame. */ setSize(600,600);//Size of JFrame setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true);//Sets if its visible. /* * JButton. */ JButton startButton = new JButton("Start");//The JButton name. add(startButton);//Add the button to the JFrame. startButton.addActionListener(this);//Reads the action. } /* *The main method. */ public static void main(String[] args){ new Main();//Reads method main() } /* *What the button does. */ public void actionPerformed(ActionEvent e) { System.out.println("The Button Works!");//what the button says when clicked. } }
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks