Creating JToggleButton Components : JToggleButton « Swing « Java Tutorial






Eight constructors are available for JToggleButton:

public JToggleButton()
JToggleButton aToggleButton = new JToggleButton();

public JToggleButton(Icon icon)
JToggleButton aToggleButton = new JToggleButton(new DiamondIcon(Color.PINK))

public JToggleButton(Icon icon, boolean selected)
JToggleButton aToggleButton = new JToggleButton(new DiamondIcon(Color.PINK), true);

public JToggleButton(String text)
JToggleButton aToggleButton = new JToggleButton("Sicilian");

public JToggleButton(String text, boolean selected)
JToggleButton aToggleButton = new JToggleButton("Thin Crust", true);

public JToggleButton(String text, Icon icon)
JToggleButton aToggleButton = new JToggleButton("Thick Crust",  new DiamondIcon(Color.PINK));

public JToggleButton(String text, Icon icon, boolean selected)
JToggleButton aToggleButton = new JToggleButton("Stuffed Crust",  new DiamondIcon(Color.PINK), true);

public JToggleButton(Action action)
Action action = ...;
JToggleButton aToggleButton = new JToggleButton(action);








14.8.JToggleButton
14.8.1.Creating JToggleButton Components
14.8.2.JToggleButton is a button that has two states. Pressed and not pressed.
14.8.3.Listening to JToggleButton Events with an ActionListenerListening to JToggleButton Events with an ActionListener
14.8.4.Listening to JToggleButton Events with an ItemListenerListening to JToggleButton Events with an ItemListener
14.8.5.Listening to JToggleButton Events with a ChangeListenerListening to JToggleButton Events with a ChangeListener
14.8.6.The event sequence for JToggleButton: ActionListener, ItemListener and ChangeListenerThe event sequence for JToggleButton: ActionListener, ItemListener and ChangeListener
14.8.7.Customizing JToggleButton Look and Feel
14.8.8.This class represents the toggle buttons used in toolbars.