Java Swing Key Action getTypePanel(final ActionListener typeListener)

Here you can find the source of getTypePanel(final ActionListener typeListener)

Description

get Type Panel

License

Open Source License

Declaration

static JPanel getTypePanel(final ActionListener typeListener) 

Method Source Code

//package com.java2s;
/********************************************************************************
 * Copyright (c) 2009 Regents of the University of Minnesota
 *
 * This Software was written at the Minnesota Supercomputing Institute
 * http://msi.umn.edu/*from w  w  w . j  a v a  2 s  . com*/
 *
 * All rights reserved. The following statement of license applies
 * only to this file, and and not to the other files distributed with it
 * or derived therefrom.  This file is made available under the terms of
 * the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Minnesota Supercomputing Institute - initial API and implementation
 *******************************************************************************/

import java.awt.Component;

import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;

import javax.swing.JLabel;

import javax.swing.JPanel;
import javax.swing.JRadioButton;

public class Main {
    static JPanel getTypePanel(final ActionListener typeListener) {
        final JRadioButton fourPlexButton = new JRadioButton("4-plex");
        fourPlexButton.setMnemonic(KeyEvent.VK_4);
        fourPlexButton.setSelected(true);
        fourPlexButton.setActionCommand("4");

        final JRadioButton eightPlexButton = new JRadioButton("8-plex");
        eightPlexButton.setMnemonic(KeyEvent.VK_8);
        eightPlexButton.setActionCommand("8");

        final ButtonGroup typeGroup = new ButtonGroup();
        typeGroup.add(fourPlexButton);
        typeGroup.add(eightPlexButton);

        final JPanel typePanel = new JPanel();

        typePanel.setLayout(new BoxLayout(typePanel, BoxLayout.LINE_AXIS));
        typePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
        typePanel.add(new JLabel("Label Type:"));
        typePanel.add(fourPlexButton);
        typePanel.add(eightPlexButton);

        fourPlexButton.addActionListener(typeListener);
        eightPlexButton.addActionListener(typeListener);

        return typePanel;
    }
}

Related

  1. getKeyStrokeCopy()
  2. getKeyStrokeRepresentation(KeyStroke ks)
  3. getKeyStrokeText(KeyStroke ks)
  4. getPrettyStringFor(KeyStroke keyStroke)
  5. getSystemHelpKey()
  6. handleSliderAdjustmentViaKey(KeyEvent e)
  7. initButton(String text, String actionKey, int shortcutKey, int modifiers, JComponent component, AbstractAction action)
  8. installCloseKey(final RootPaneContainer c)
  9. invoke(Action action, Object source)