CheckBox Mnemonic : CheckBox Button « Swing JFC « Java






CheckBox Mnemonic

CheckBox Mnemonic
  

import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

public class CheckBoxMnemonic extends JPanel {
  public CheckBoxMnemonic() {
    JCheckBox m_chkBold = new JCheckBox("Bold");
    m_chkBold.setMnemonic('b');
    m_chkBold.setToolTipText("Bold font");
    add(m_chkBold);
    setBorder(new TitledBorder(new EtchedBorder(), "Effects"));
    JCheckBox m_chkItalic = new JCheckBox("Italic");
    m_chkItalic.setMnemonic('i');
    m_chkItalic.setToolTipText("Italic font");
    add(m_chkItalic);
    JCheckBox m_chkUnderline = new JCheckBox("Underline");
    m_chkUnderline.setMnemonic('u');
    m_chkUnderline.setToolTipText("Underline font");
    add(m_chkUnderline);
    JCheckBox m_chkStrikethrough = new JCheckBox("Strikethrough");
    m_chkStrikethrough.setMnemonic('r');
    m_chkStrikethrough.setToolTipText("Strikethrough font");
    add(m_chkStrikethrough);
    JCheckBox m_chkSubscript = new JCheckBox("Subscript");
    m_chkSubscript.setMnemonic('t');
    m_chkSubscript.setToolTipText("Subscript font");
    add(m_chkSubscript);
    JCheckBox m_chkSuperscript = new JCheckBox("Superscript");
    m_chkSuperscript.setMnemonic('p');
    m_chkSuperscript.setToolTipText("Superscript font");
    add(m_chkSuperscript);

  }

  public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
    f.getContentPane().add(new CheckBoxMnemonic());
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.show();

  }
}


           
         
    
  








Related examples in the same category

1.JCheckBox is a widget that has two states. On and Off.
2.Swing CheckBoxesSwing CheckBoxes
3.CheckBox Demo 2CheckBox Demo 2
4. How to use the check box button How to use the check box button
5.Bad Checkbox UIBad Checkbox UI
6.React to menu action and checkbox menuReact to menu action and checkbox menu
7.Swing CheckBox DemoSwing CheckBox Demo
8.CheckBox Item ListenerCheckBox Item Listener
9.Icon CheckBox DemoIcon CheckBox Demo
10.Flat CheckBoxFlat CheckBox
11.Customizing the Icons in a JCheckBox Component
12.Customize these disabled icons
13.Set pressed icon
14.Display an icon when the cursor is moved over the checkbox. This is called the rollover icon.
15.Adding an Icon to the Label of a JCheckBox Component
16.Getting and Setting the State of a JCheckbox Component
17.Creating a JCheckbox Component
18.Check boxes with item changed event.
19.Get or set the selection state of JCheckBox
20.Customize JCheckBox icons
21.Radio button, ComboBoxRadio button, ComboBox
22.Using CheckBox ActionListener to controll font