Example usage for java.awt.event KeyEvent VK_G

List of usage examples for java.awt.event KeyEvent VK_G

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_G.

Prototype

int VK_G

To view the source code for java.awt.event KeyEvent VK_G.

Click Source Link

Document

Constant for the "G" key.

Usage

From source file:Main.java

public static void main(String[] args) {

    JRadioButton button1 = new JRadioButton("Red");
    JRadioButton button2 = new JRadioButton("Green");

    button2.setMnemonic(KeyEvent.VK_G);

    JRadioButton button3 = new JRadioButton("Blue");
    ButtonGroup colorButtonGroup = new ButtonGroup();
    colorButtonGroup.add(button1);/* w ww.  ja v a2 s  .  co m*/
    colorButtonGroup.add(button2);
    colorButtonGroup.add(button3);
    button1.setSelected(true);

    JFrame frame = new JFrame();
    frame.setLayout(new FlowLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new JLabel("Color:"));
    frame.add(button1);
    frame.add(button2);
    frame.add(button3);
    frame.pack();
    frame.setVisible(true);

}

From source file:TabSample.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Tabbed Pane Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTabbedPane tabbedPane = new JTabbedPane();

    String titles[] = { "General", "Security", "Content", "Connection", "Programs", "Advanced" };
    int mnemonic[] = { KeyEvent.VK_G, KeyEvent.VK_S, KeyEvent.VK_C, KeyEvent.VK_O, KeyEvent.VK_P,
            KeyEvent.VK_A };/* w  w  w.j a va  2 s .  c  o  m*/
    for (int i = 0, n = titles.length; i < n; i++) {
        add(tabbedPane, titles[i], mnemonic[i]);
    }

    frame.add(tabbedPane, BorderLayout.CENTER);
    frame.setSize(400, 150);
    frame.setVisible(true);
}

From source file:TabLocation.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Tabbed Pane Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTabbedPane tabbedPane = new JTabbedPane();

    String titles[] = { "General", "Security", "Content", "Connection", "Programs", "Advanced" };
    int mnemonic[] = { KeyEvent.VK_G, KeyEvent.VK_S, KeyEvent.VK_C, KeyEvent.VK_O, KeyEvent.VK_P,
            KeyEvent.VK_A };//from  w ww .j  av  a2s.  c  o m
    for (int i = 0, n = titles.length; i < n; i++) {
        add(tabbedPane, titles[i], mnemonic[i]);
    }

    tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
    frame.add(tabbedPane, BorderLayout.CENTER);
    frame.setSize(400, 150);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tabbed Pane Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    String titles[] = { "General", "Security", "Content", "Connection", "Programs", "Advanced" };
    int mnemonic[] = { KeyEvent.VK_G, KeyEvent.VK_S, KeyEvent.VK_C, KeyEvent.VK_O, KeyEvent.VK_P,
            KeyEvent.VK_A };/*from  w w  w  . ja  va  2  s .  co  m*/
    for (int i = 0, n = titles.length; i < n; i++) {
        add(tabbedPane, titles[i], mnemonic[i]);
    }

    tabbedPane.removeAll();
    frame.add(tabbedPane, BorderLayout.CENTER);
    frame.setSize(400, 150);
    frame.setVisible(true);
}

From source file:TabSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tabbed Pane Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTabbedPane tabbedPane = new JTabbedPane();
    String titles[] = { "General", "Security", "Content", "Connection", "Programs", "Advanced" };
    int mnemonic[] = { KeyEvent.VK_G, KeyEvent.VK_S, KeyEvent.VK_C, KeyEvent.VK_O, KeyEvent.VK_P,
            KeyEvent.VK_A };//from www  .java 2  s  .  c  o  m
    for (int i = 0, n = titles.length; i < n; i++) {
        add(tabbedPane, titles[i], mnemonic[i]);
        tabbedPane.setBackgroundAt(i, colors[i]);
    }
    frame.add(tabbedPane, BorderLayout.CENTER);
    frame.setSize(400, 150);
    frame.setVisible(true);
}

From source file:Main.java

/**
 * Returns the mnemonic integer./*from  www. jav  a2s.  c  o m*/
 * 
 * @param c The character (uppercase)
 * @return The mnemonic.
 */
@SuppressWarnings("incomplete-switch")
private static int setMnemonicsGet(char c) {
    int mnemonic = 0;
    switch (Character.toUpperCase(c)) {
    case '0':
        mnemonic = KeyEvent.VK_0;
        break;
    case '1':
        mnemonic = KeyEvent.VK_1;
        break;
    case '2':
        mnemonic = KeyEvent.VK_2;
        break;
    case '3':
        mnemonic = KeyEvent.VK_3;
        break;
    case '4':
        mnemonic = KeyEvent.VK_4;
        break;
    case '5':
        mnemonic = KeyEvent.VK_5;
        break;
    case '6':
        mnemonic = KeyEvent.VK_6;
        break;
    case '7':
        mnemonic = KeyEvent.VK_7;
        break;
    case '8':
        mnemonic = KeyEvent.VK_8;
        break;
    case '9':
        mnemonic = KeyEvent.VK_9;
        break;
    case 'A':
        mnemonic = KeyEvent.VK_A;
        break;
    case 'B':
        mnemonic = KeyEvent.VK_B;
        break;
    case 'C':
        mnemonic = KeyEvent.VK_C;
        break;
    case 'D':
        mnemonic = KeyEvent.VK_D;
        break;
    case 'E':
        mnemonic = KeyEvent.VK_E;
        break;
    case 'F':
        mnemonic = KeyEvent.VK_F;
        break;
    case 'G':
        mnemonic = KeyEvent.VK_G;
        break;
    case 'H':
        mnemonic = KeyEvent.VK_H;
        break;
    case 'I':
        mnemonic = KeyEvent.VK_I;
        break;
    case 'J':
        mnemonic = KeyEvent.VK_J;
        break;
    case 'K':
        mnemonic = KeyEvent.VK_K;
        break;
    case 'L':
        mnemonic = KeyEvent.VK_L;
        break;
    case 'M':
        mnemonic = KeyEvent.VK_M;
        break;
    case 'N':
        mnemonic = KeyEvent.VK_N;
        break;
    case 'O':
        mnemonic = KeyEvent.VK_O;
        break;
    case 'P':
        mnemonic = KeyEvent.VK_P;
        break;
    case 'Q':
        mnemonic = KeyEvent.VK_Q;
        break;
    case 'R':
        mnemonic = KeyEvent.VK_R;
        break;
    case 'S':
        mnemonic = KeyEvent.VK_S;
        break;
    case 'T':
        mnemonic = KeyEvent.VK_T;
        break;
    case 'U':
        mnemonic = KeyEvent.VK_U;
        break;
    case 'V':
        mnemonic = KeyEvent.VK_V;
        break;
    case 'W':
        mnemonic = KeyEvent.VK_W;
        break;
    case 'X':
        mnemonic = KeyEvent.VK_X;
        break;
    case 'Y':
        mnemonic = KeyEvent.VK_Y;
        break;
    case 'Z':
        mnemonic = KeyEvent.VK_Z;
        break;
    }
    return mnemonic;
}

From source file:org.gitools.ui.app.actions.file.OpenFromGenomeSpaceAction.java

public OpenFromGenomeSpaceAction() {
    super("Open from Genomespace...");
    setDesc("Open a heatmap or an analysis from Genomespace");
    setLargeIconFromResource(IconNames.gs24);
    setSmallIconFromResource(IconNames.gs16);
    setMnemonic(KeyEvent.VK_G);
    setDefaultEnabled(true);//  www .  java2s. c om
}

From source file:components.CheckBoxDemo.java

public CheckBoxDemo() {
    super(new BorderLayout());

    //Create the check boxes.
    chinButton = new JCheckBox("Chin");
    chinButton.setMnemonic(KeyEvent.VK_C);
    chinButton.setSelected(true);/*  w  w w .j a v a  2s. c om*/

    glassesButton = new JCheckBox("Glasses");
    glassesButton.setMnemonic(KeyEvent.VK_G);
    glassesButton.setSelected(true);

    hairButton = new JCheckBox("Hair");
    hairButton.setMnemonic(KeyEvent.VK_H);
    hairButton.setSelected(true);

    teethButton = new JCheckBox("Teeth");
    teethButton.setMnemonic(KeyEvent.VK_T);
    teethButton.setSelected(true);

    //Register a listener for the check boxes.
    chinButton.addItemListener(this);
    glassesButton.addItemListener(this);
    hairButton.addItemListener(this);
    teethButton.addItemListener(this);

    //Indicates what's on the geek.
    choices = new StringBuffer("cght");

    //Set up the picture label
    pictureLabel = new JLabel();
    pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC));
    updatePicture();

    //Put the check boxes in a column in a panel
    JPanel checkPanel = new JPanel(new GridLayout(0, 1));
    checkPanel.add(chinButton);
    checkPanel.add(glassesButton);
    checkPanel.add(hairButton);
    checkPanel.add(teethButton);

    add(checkPanel, BorderLayout.LINE_START);
    add(pictureLabel, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:CheckBoxDemo.java

public CheckBoxDemo() {
    super(new BorderLayout());

    // Create the check boxes.
    chinButton = new JCheckBox("Chin");
    chinButton.setMnemonic(KeyEvent.VK_C);
    chinButton.setSelected(true);//from  ww  w. j  a va  2s  .  co m

    glassesButton = new JCheckBox("Glasses");
    glassesButton.setMnemonic(KeyEvent.VK_G);
    glassesButton.setSelected(true);

    hairButton = new JCheckBox("Hair");
    hairButton.setMnemonic(KeyEvent.VK_H);
    hairButton.setSelected(true);

    teethButton = new JCheckBox("Teeth");
    teethButton.setMnemonic(KeyEvent.VK_T);
    teethButton.setSelected(true);

    // Register a listener for the check boxes.
    chinButton.addItemListener(this);
    glassesButton.addItemListener(this);
    hairButton.addItemListener(this);
    teethButton.addItemListener(this);

    // Indicates what's on the geek.
    choices = new StringBuffer("cght");

    // Set up the picture label
    pictureLabel = new JLabel();
    pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC));
    updatePicture();

    // Put the check boxes in a column in a panel
    JPanel checkPanel = new JPanel(new GridLayout(0, 1));
    checkPanel.add(chinButton);
    checkPanel.add(glassesButton);
    checkPanel.add(hairButton);
    checkPanel.add(teethButton);

    add(checkPanel, BorderLayout.LINE_START);
    add(pictureLabel, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:SwingCheckBoxDemo.java

public SwingCheckBoxDemo() {
    super(new BorderLayout());

    //Create the check boxes.
    chinButton = new JCheckBox("Chin");
    chinButton.setMnemonic(KeyEvent.VK_C);
    chinButton.setSelected(true);// w  w w . j ava  2s.  c  om

    glassesButton = new JCheckBox("Glasses");
    glassesButton.setMnemonic(KeyEvent.VK_G);
    glassesButton.setSelected(true);

    hairButton = new JCheckBox("Hair");
    hairButton.setMnemonic(KeyEvent.VK_H);
    hairButton.setSelected(true);

    teethButton = new JCheckBox("Teeth");
    teethButton.setMnemonic(KeyEvent.VK_T);
    teethButton.setSelected(true);

    //Register a listener for the check boxes.
    chinButton.addItemListener(this);
    glassesButton.addItemListener(this);
    hairButton.addItemListener(this);
    teethButton.addItemListener(this);

    //Indicates what's on the geek.
    choices = new StringBuffer("cght");

    //Set up the picture label
    pictureLabel = new JLabel();
    pictureLabel.setFont(pictureLabel.getFont().deriveFont(Font.ITALIC));
    updatePicture();

    /*Put the check boxes in a column in a panel*/

    JPanel checkPanel = new JPanel(new GridLayout(0, 1));
    checkPanel.add(chinButton);
    checkPanel.add(glassesButton);
    checkPanel.add(hairButton);
    checkPanel.add(teethButton);

    add(checkPanel, BorderLayout.LINE_START);
    add(pictureLabel, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}