Created
July 1, 2013 14:04
-
-
Save alexrios/5901042 to your computer and use it in GitHub Desktop.
Liga e Desliga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
public class JCheckBoxActionListener { | |
public static void main(String args[]) { | |
JFrame frame = new JFrame("Iconizing CheckBox"); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
JCheckBox aCheckBox4 = new JCheckBox("Stuffed Crust"); | |
ActionListener actionListener = new ActionListener() { | |
public void actionPerformed(ActionEvent actionEvent) { | |
AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); | |
boolean selected = abstractButton.getModel().isSelected(); | |
System.out.println(selected); | |
// abstractButton.setText(newLabel); | |
} | |
}; | |
aCheckBox4.addActionListener(actionListener); | |
frame.add(aCheckBox4); | |
frame.setSize(300, 200); | |
frame.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment