Skip to main content

Student Portal > Contests > 

Programming Contest Central

   
Welcome students Resources Competition ProfilesFAQ
  Contest calendar
  Problem of the month
  Past problems
  Games and brainteasers
  Successes
  Tutorials

JButton

/**
 *Creating a JButton is just as simple as creating a JLabel
 *or JPanel.
 */

// Creates a Content Pane for the button layout.
Container content = getContentPane();

// Creates a new button with the text “Button”.
JButton button = new JButton(“Button”);
content.add(button);

// Creates a new button with the text “Second Button”.
JButton button2 = new JButton(“Second Button”);
content.add(button2);

// Creates a new button with the text “Third Button”.
JButton button3 = new JButton(“Third Button”);
content.add(button3);


Back to top
 


Quick links

Student forum

Teacher resources

RSS Feed