Java JCheckBox set mnemonic key

Description

Java JCheckBox set mnemonic key

import java.awt.FlowLayout;

import javax.swing.JCheckBox;
import javax.swing.JFrame;

public class Main extends JFrame {
  public Main() {
    super("JButton");

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new FlowLayout());

    //from ww w  .j  a v  a 2s  . c  o  m
    JCheckBox checkBox = new JCheckBox("CheckBox");
    checkBox.setMnemonic('C');

    getContentPane().add(checkBox);
  }

  public static void main(String[] args) {
    Main frame = new Main();
    frame.pack();
    frame.setVisible(true);
  }
}



PreviousNext

Related