Search in sources :

Example 51 with JToggleButton

use of javax.swing.JToggleButton in project chuidiang-ejemplos by chuidiang.

the class ToggleButtonExample method main.

public static void main(String[] args) {
    JFrame frame = new JFrame("JToggleButton Example");
    check = new JToggleButton("Push here ");
    check2 = new JToggleButton("I'm a mirror");
    frame.getContentPane().add(check);
    frame.getContentPane().setLayout(new FlowLayout());
    frame.getContentPane().add(check2);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    check.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            check2.setSelected(check.isSelected());
        }
    });
}
Also used : FlowLayout(java.awt.FlowLayout) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) JFrame(javax.swing.JFrame) ActionEvent(java.awt.event.ActionEvent)

Aggregations

JToggleButton (javax.swing.JToggleButton)51 ActionEvent (java.awt.event.ActionEvent)19 ActionListener (java.awt.event.ActionListener)19 JPanel (javax.swing.JPanel)17 JLabel (javax.swing.JLabel)16 ImageIcon (javax.swing.ImageIcon)14 JButton (javax.swing.JButton)12 Dimension (java.awt.Dimension)8 JScrollPane (javax.swing.JScrollPane)8 ChangeEvent (javax.swing.event.ChangeEvent)8 ChangeListener (javax.swing.event.ChangeListener)8 BoxLayout (javax.swing.BoxLayout)7 JCheckBox (javax.swing.JCheckBox)6 JSlider (javax.swing.JSlider)6 GridBagLayout (java.awt.GridBagLayout)5 GridLayout (java.awt.GridLayout)5 JTabbedPane (javax.swing.JTabbedPane)5 JToolBar (javax.swing.JToolBar)5 BorderLayout (java.awt.BorderLayout)4 Component (java.awt.Component)4