Skip to content

Instantly share code, notes, and snippets.

@alexrios
Created July 1, 2013 14:04
Show Gist options
  • Save alexrios/5901042 to your computer and use it in GitHub Desktop.
Save alexrios/5901042 to your computer and use it in GitHub Desktop.
Liga e Desliga
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