Sunday, 27 January 2013

JButton


To create a button, Java provides the class JButton and the following methods:

public JButton(Icon ic)
public JButton(String str)
public JButton(String str, Icon ic)
public void setText(String str)
public String getText()
public void setEditable(Boolean b)
public void addActionListener(ActionListener obj)

The add method can then be used to add buttons to the content pane.

Teaching Tip

Components such as JButton, JTextField, and JLabel are part of Java’s Swing framework.  A tutorial on creating GUI interfaces with Swing can be found at:

No comments:

Post a Comment