Example usage for java.awt.event KeyEvent VK_S

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

Introduction

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

Prototype

int VK_S

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

Click Source Link

Document

Constant for the "S" key.

Usage

From source file:com.nbt.TreeFrame.java

private void createActions() {
    newAction = new NBTAction("New", "New", "New", KeyEvent.VK_N) {

        {//  w ww.  j a va2 s.c  o  m
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N', Event.CTRL_MASK));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            updateTreeTable(new CompoundTag(""));
        }

    };

    browseAction = new NBTAction("Browse...", "Open", "Browse...", KeyEvent.VK_O) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('O', Event.CTRL_MASK));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = createFileChooser();
            switch (fc.showOpenDialog(TreeFrame.this)) {
            case JFileChooser.APPROVE_OPTION:
                File file = fc.getSelectedFile();
                Preferences prefs = getPreferences();
                prefs.put(KEY_FILE, file.getAbsolutePath());
                doImport(file);
                break;
            }
        }

    };

    saveAction = new NBTAction("Save", "Save", "Save", KeyEvent.VK_S) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S', Event.CTRL_MASK));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            String path = textFile.getText();
            File file = new File(path);
            if (file.canWrite()) {
                doExport(file);
            } else {
                saveAsAction.actionPerformed(e);
            }
        }

    };

    saveAsAction = new NBTAction("Save As...", "SaveAs", "Save As...", KeyEvent.VK_UNDEFINED) {

        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = createFileChooser();
            switch (fc.showSaveDialog(TreeFrame.this)) {
            case JFileChooser.APPROVE_OPTION:
                File file = fc.getSelectedFile();
                Preferences prefs = getPreferences();
                prefs.put(KEY_FILE, file.getAbsolutePath());
                doExport(file);
                break;
            }
        }

    };

    refreshAction = new NBTAction("Refresh", "Refresh", "Refresh", KeyEvent.VK_F5) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F5"));
        }

        public void actionPerformed(ActionEvent e) {
            String path = textFile.getText();
            File file = new File(path);
            if (file.canRead())
                doImport(file);
            else
                showErrorDialog("The file could not be read.");
        }

    };

    exitAction = new NBTAction("Exit", "Exit", KeyEvent.VK_ESCAPE) {

        @Override
        public void actionPerformed(ActionEvent e) {
            // TODO: this should check to see if any changes have been made
            // before exiting
            System.exit(0);
        }

    };

    cutAction = new DefaultEditorKit.CutAction() {

        {
            String name = "Cut";
            putValue(NAME, name);
            putValue(SHORT_DESCRIPTION, name);
            putValue(MNEMONIC_KEY, KeyEvent.VK_X);
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('X', Event.CTRL_MASK));

            ImageFactory factory = new ImageFactory();
            try {
                putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize)));
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                putValue(LARGE_ICON_KEY,
                        new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize)));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };

    copyAction = new DefaultEditorKit.CopyAction() {

        {
            String name = "Copy";
            putValue(NAME, name);
            putValue(SHORT_DESCRIPTION, name);
            putValue(MNEMONIC_KEY, KeyEvent.VK_C);
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('C', Event.CTRL_MASK));

            ImageFactory factory = new ImageFactory();
            try {
                putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize)));
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                putValue(LARGE_ICON_KEY,
                        new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize)));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };

    pasteAction = new DefaultEditorKit.CutAction() {

        {
            String name = "Paste";
            putValue(NAME, name);
            putValue(SHORT_DESCRIPTION, name);
            putValue(MNEMONIC_KEY, KeyEvent.VK_V);
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('V', Event.CTRL_MASK));

            ImageFactory factory = new ImageFactory();
            try {
                putValue(SMALL_ICON, new ImageIcon(factory.readGeneralImage(name, NBTAction.smallIconSize)));
            } catch (IOException e) {
                e.printStackTrace();
            }

            try {
                putValue(LARGE_ICON_KEY,
                        new ImageIcon(factory.readGeneralImage(name, NBTAction.largeIconSize)));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    };

    deleteAction = new NBTAction("Delete", "Delete", "Delete", KeyEvent.VK_DELETE) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE"));
        }

        public void actionPerformed(ActionEvent e) {
            int row = treeTable.getSelectedRow();
            TreePath path = treeTable.getPathForRow(row);
            Object last = path.getLastPathComponent();

            if (last instanceof NBTFileBranch) {
                NBTFileBranch branch = (NBTFileBranch) last;
                File file = branch.getFile();
                String name = file.getName();
                String message = "Are you sure you want to delete " + name + "?";
                String title = "Continue?";
                int option = JOptionPane.showConfirmDialog(TreeFrame.this, message, title,
                        JOptionPane.OK_CANCEL_OPTION);
                switch (option) {
                case JOptionPane.CANCEL_OPTION:
                    return;
                }
                if (!FileUtils.deleteQuietly(file)) {
                    showErrorDialog(name + " could not be deleted.");
                    return;
                }
            }

            TreePath parentPath = path.getParentPath();
            Object parentLast = parentPath.getLastPathComponent();
            NBTTreeTableModel model = treeTable.getTreeTableModel();
            int index = model.getIndexOfChild(parentLast, last);
            if (parentLast instanceof Mutable<?>) {
                Mutable<?> mutable = (Mutable<?>) parentLast;
                if (last instanceof ByteWrapper) {
                    ByteWrapper wrapper = (ByteWrapper) last;
                    index = wrapper.getIndex();
                }
                mutable.remove(index);
            } else {
                System.err.println(last.getClass());
                return;
            }

            updateTreeTable();
            treeTable.expandPath(parentPath);
            scrollTo(parentLast);
            treeTable.setRowSelectionInterval(row, row);
        }

    };

    openAction = new NBTAction("Open...", "Open...", KeyEvent.VK_T) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('T', Event.CTRL_MASK));

            final int diamondPickaxe = 278;
            SpriteRecord record = NBTTreeTable.register.getRecord(diamondPickaxe);
            BufferedImage image = record.getImage();
            setSmallIcon(image);

            int width = 24, height = 24;
            Dimension size = new Dimension(width, height);
            Map<RenderingHints.Key, ?> hints = Thumbnail.createRenderingHints(Thumbnail.QUALITY);
            BufferedImage largeImage = Thumbnail.createThumbnail(image, size, hints);
            setLargeIcon(largeImage);
        }

        public void actionPerformed(ActionEvent e) {
            TreePath path = treeTable.getPath();
            if (path == null)
                return;

            Object last = path.getLastPathComponent();
            if (last instanceof Region) {
                Region region = (Region) last;
                createAndShowTileCanvas(new TileCanvas.TileWorld(region));
                return;
            } else if (last instanceof World) {
                World world = (World) last;
                createAndShowTileCanvas(world);
                return;
            }

            if (last instanceof NBTFileBranch) {
                NBTFileBranch fileBranch = (NBTFileBranch) last;
                File file = fileBranch.getFile();
                try {
                    open(file);
                } catch (IOException ex) {
                    ex.printStackTrace();
                    showErrorDialog(ex.getMessage());
                }
            }
        }

        private void open(File file) throws IOException {
            if (Desktop.isDesktopSupported()) {
                Desktop desktop = Desktop.getDesktop();
                if (desktop.isSupported(Desktop.Action.OPEN)) {
                    desktop.open(file);
                }
            }
        }

    };

    addByteAction = new NBTAction("Add Byte", NBTConstants.TYPE_BYTE, "Add Byte", KeyEvent.VK_1) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('1', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new ByteTag("new byte", (byte) 0));
        }

    };

    addShortAction = new NBTAction("Add Short", NBTConstants.TYPE_SHORT, "Add Short", KeyEvent.VK_2) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('2', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new ShortTag("new short", (short) 0));
        }

    };

    addIntAction = new NBTAction("Add Integer", NBTConstants.TYPE_INT, "Add Integer", KeyEvent.VK_3) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('3', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new IntTag("new int", 0));
        }

    };

    addLongAction = new NBTAction("Add Long", NBTConstants.TYPE_LONG, "Add Long", KeyEvent.VK_4) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('4', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new LongTag("new long", 0));
        }

    };

    addFloatAction = new NBTAction("Add Float", NBTConstants.TYPE_FLOAT, "Add Float", KeyEvent.VK_5) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('5', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new FloatTag("new float", 0));
        }

    };

    addDoubleAction = new NBTAction("Add Double", NBTConstants.TYPE_DOUBLE, "Add Double", KeyEvent.VK_6) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('6', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new DoubleTag("new double", 0));
        }

    };

    addByteArrayAction = new NBTAction("Add Byte Array", NBTConstants.TYPE_BYTE_ARRAY, "Add Byte Array",
            KeyEvent.VK_7) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('7', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new ByteArrayTag("new byte array"));
        }

    };

    addStringAction = new NBTAction("Add String", NBTConstants.TYPE_STRING, "Add String", KeyEvent.VK_8) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('8', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new StringTag("new string", "..."));
        }

    };

    addListAction = new NBTAction("Add List Tag", NBTConstants.TYPE_LIST, "Add List Tag", KeyEvent.VK_9) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('9', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            Class<? extends Tag> type = queryType();
            if (type != null)
                addTag(new ListTag("new list", null, type));
        }

        private Class<? extends Tag> queryType() {
            Object[] items = { NBTConstants.TYPE_BYTE, NBTConstants.TYPE_SHORT, NBTConstants.TYPE_INT,
                    NBTConstants.TYPE_LONG, NBTConstants.TYPE_FLOAT, NBTConstants.TYPE_DOUBLE,
                    NBTConstants.TYPE_BYTE_ARRAY, NBTConstants.TYPE_STRING, NBTConstants.TYPE_LIST,
                    NBTConstants.TYPE_COMPOUND };
            JComboBox comboBox = new JComboBox(new DefaultComboBoxModel(items));
            comboBox.setRenderer(new DefaultListCellRenderer() {

                @Override
                public Component getListCellRendererComponent(JList list, Object value, int index,
                        boolean isSelected, boolean cellHasFocus) {
                    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

                    if (value instanceof Integer) {
                        Integer i = (Integer) value;
                        Class<? extends Tag> c = NBTUtils.getTypeClass(i);
                        String name = NBTUtils.getTypeName(c);
                        setText(name);
                    }

                    return this;
                }

            });
            Object[] message = { new JLabel("Please select a type."), comboBox };
            String title = "Title goes here";
            int result = JOptionPane.showOptionDialog(TreeFrame.this, message, title,
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
            switch (result) {
            case JOptionPane.OK_OPTION:
                ComboBoxModel model = comboBox.getModel();
                Object item = model.getSelectedItem();
                if (item instanceof Integer) {
                    Integer i = (Integer) item;
                    return NBTUtils.getTypeClass(i);
                }
            }
            return null;
        }

    };

    addCompoundAction = new NBTAction("Add Compound Tag", NBTConstants.TYPE_COMPOUND, "Add Compound Tag",
            KeyEvent.VK_0) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('0', Event.CTRL_MASK));
        }

        public void actionPerformed(ActionEvent e) {
            addTag(new CompoundTag());
        }

    };

    String name = "About " + TITLE;
    helpAction = new NBTAction(name, "Help", name, KeyEvent.VK_F1) {

        {
            putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("F1"));
        }

        public void actionPerformed(ActionEvent e) {
            Object[] message = { new JLabel(TITLE + " " + VERSION),
                    new JLabel("\u00A9 Copyright Taggart Spilman 2011.  All rights reserved."),
                    new Hyperlink("<html><a href=\"#\">NamedBinaryTag.com</a></html>",
                            "http://www.namedbinarytag.com"),
                    new Hyperlink("<html><a href=\"#\">Contact</a></html>", "mailto:tagadvance@gmail.com"),
                    new JLabel(" "),
                    new Hyperlink("<html><a href=\"#\">JNBT was written by Graham Edgecombe</a></html>",
                            "http://jnbt.sf.net"),
                    new Hyperlink("<html><a href=\"#\">Available open-source under the BSD license</a></html>",
                            "http://jnbt.sourceforge.net/LICENSE.TXT"),
                    new JLabel(" "), new JLabel("This product includes software developed by"),
                    new Hyperlink("<html><a href=\"#\">The Apache Software Foundation</a>.</html>",
                            "http://www.apache.org"),
                    new JLabel(" "), new JLabel("Default texture pack:"),
                    new Hyperlink("<html><a href=\"#\">SOLID COLOUR. SOLID STYLE.</a></html>",
                            "http://www.minecraftforum.net/topic/72253-solid-colour-solid-style/"),
                    new JLabel("Bundled with the permission of Trigger_Proximity."),

            };
            String title = "About";
            JOptionPane.showMessageDialog(TreeFrame.this, message, title, JOptionPane.INFORMATION_MESSAGE);
        }

    };

}

From source file:net.sf.firemox.DeckBuilder.java

/**
 * Creates new form DeckBuilder/*from  w  w w. j a v  a  2  s  .  c om*/
 */
private DeckBuilder() {
    super("DeckBuilder");
    form = this;
    timerPanel = new TimerGlassPane();
    cardLoader = new CardLoader(timerPanel);
    timer = new Timer(200, cardLoader);
    setGlassPane(timerPanel);
    try {
        setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif"));
    } catch (Exception e) {
        // IGNORING
    }

    // Load settings
    loadSettings();

    // Initialize components
    final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this);
    loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

    final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this);
    saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0));

    final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

    final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this);
    quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));

    final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this);
    deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));

    final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this);
    aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK));

    final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this);

    final JMenu mainMenu = UIHelper.buildMenu("menu_file");
    mainMenu.add(newItem);
    mainMenu.add(loadItem);
    mainMenu.add(saveAsItem);
    mainMenu.add(saveItem);
    mainMenu.add(new JSeparator());
    mainMenu.add(quitItem);

    super.optionMenu = new JMenu("Options");

    final JMenu convertMenu = UIHelper.buildMenu("menu_convert");
    convertMenu.add(convertDCK);

    final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this);
    helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

    final JMenu helpMenu = new JMenu("?");
    helpMenu.add(helpItem);
    helpMenu.add(deckConstraintsItem);
    helpMenu.add(aboutItem);

    final JMenuBar menuBar = new JMenuBar();
    menuBar.add(mainMenu);
    initAbstractMenu();
    menuBar.add(optionMenu);
    menuBar.add(convertMenu);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    addWindowListener(this);

    // Build the panel containing amount of available cards
    final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT);

    // Build the left list
    allListModel = new MListModel<MCardCompare>(amountLeft, false);
    leftList = new ThreadSafeJList(allListModel);
    leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leftList.setLayoutOrientation(JList.VERTICAL);
    leftList.getSelectionModel().addListSelectionListener(this);
    leftList.addMouseListener(this);
    leftList.setVisibleRowCount(10);

    // Initialize the text field containing the amount to add
    addQtyTxt = new JTextField("1");

    // Build the "Add" button
    addButton = new JButton(LanguageManager.getString("db_add"));
    addButton.setMnemonic('a');
    addButton.setEnabled(false);

    // Build the panel containing : "Add" amount and "Add" button
    final Box addPanel = Box.createHorizontalBox();
    addPanel.add(addButton);
    addPanel.add(addQtyTxt);
    addPanel.setMaximumSize(new Dimension(32010, 26));

    // Build the panel containing the selected card name
    cardNameTxt = new JTextField();
    new HireListener(cardNameTxt, addButton, this, leftList);

    final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : ");
    searchLabel.setLabelFor(cardNameTxt);

    // Build the panel containing search label and card name text field
    final Box searchPanel = Box.createHorizontalBox();
    searchPanel.add(searchLabel);
    searchPanel.add(cardNameTxt);
    searchPanel.setMaximumSize(new Dimension(32010, 26));

    listScrollerLeft = new JScrollPane(leftList);
    MToolKit.addOverlay(listScrollerLeft);

    // Build the left panel containing : list, available amount, "Add" panel
    final JPanel srcPanel = new JPanel(null);
    srcPanel.add(searchPanel);
    srcPanel.add(listScrollerLeft);
    srcPanel.add(amountLeft);
    srcPanel.add(addPanel);
    srcPanel.setMinimumSize(new Dimension(220, 200));
    srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS));

    // Initialize constraints
    constraintsChecker = new ConstraintsChecker();
    constraintsChecker.setBorder(new EtchedBorder());
    final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker);
    MToolKit.addOverlay(constraintsCheckerScroll);

    // create a pane with the oracle text for the present card
    oracleText = new JLabel();
    oracleText.setPreferredSize(new Dimension(180, 200));
    oracleText.setVerticalAlignment(SwingConstants.TOP);

    final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(oracle);

    // build some Pie Charts and a panel to display it
    initSets();
    datasets = new ChartSets();
    final JTabbedPane tabbedPane = new JTabbedPane();
    for (ChartFilter filter : ChartFilter.values()) {
        final Dataset dataSet = filter.createDataSet(this);
        final JFreeChart chart = new JFreeChart(null, null,
                filter.createPlot(dataSet, painterMapper.get(filter)), false);
        datasets.addDataSet(filter, dataSet);
        ChartPanel pieChartPanel = new ChartPanel(chart, true);
        tabbedPane.add(pieChartPanel, filter.getTitle());
    }
    // add the Constraints scroll panel and Oracle text Pane to the tabbedPane
    tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints"));
    tabbedPane.add(oracle, LanguageManager.getString("db_text"));
    tabbedPane.setSelectedComponent(oracle);

    // The toollBar for color filtering
    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    final JButton clearButton = UIHelper.buildButton("clear");
    clearButton.addActionListener(this);
    toolBar.add(clearButton);
    final JToggleButton toggleColorlessButton = new JToggleButton(
            UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true);
    toggleColorlessButton.setActionCommand("0");
    toggleColorlessButton.addActionListener(this);
    toolBar.add(toggleColorlessButton);
    for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) {
        final JToggleButton toggleButton = new JToggleButton(
                UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true);
        toggleButton.setActionCommand(String.valueOf(index));
        toggleButton.addActionListener(this);
        toolBar.add(toggleButton);
    }

    // sorted card type combobox creation
    final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames));
    Collections.sort(idCards);
    final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") },
            idCards.toArray());
    idCardComboBox = new JComboBox(cardTypes);
    idCardComboBox.setSelectedIndex(0);
    idCardComboBox.addActionListener(this);
    idCardComboBox.setActionCommand("cardTypeFilter");

    // sorted card properties combobox creation
    final List<String> properties = new ArrayList<String>(
            CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty()));
    Collections.sort(properties);
    final Object[] cardProperties = ArrayUtils
            .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray());
    propertiesComboBox = new JComboBox(cardProperties);
    propertiesComboBox.setSelectedIndex(0);
    propertiesComboBox.addActionListener(this);
    propertiesComboBox.setActionCommand("propertyFilter");

    final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : ");
    final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : ");
    final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : ");

    // filter Panel with colors toolBar and card type combobox
    final Box filterPanel = Box.createHorizontalBox();
    filterPanel.add(colors);
    filterPanel.add(toolBar);
    filterPanel.add(types);
    filterPanel.add(idCardComboBox);
    filterPanel.add(property);
    filterPanel.add(propertiesComboBox);

    getContentPane().add(filterPanel, BorderLayout.NORTH);

    // Destination section :

    // Build the panel containing amount of available cards
    final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT);
    rightAmount.setMaximumSize(new Dimension(220, 26));

    // Build the right list
    rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true));
    rightListModel.addTableModelListener(this);
    rightList = new JTable(rightListModel);
    rightList.setShowGrid(false);
    rightList.setTableHeader(null);
    rightList.getSelectionModel().addListSelectionListener(this);
    rightList.getColumnModel().getColumn(0).setMaxWidth(25);
    rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    // Build the panel containing the selected deck
    deckNameTxt = new JTextField("loading...");
    deckNameTxt.setEditable(false);
    deckNameTxt.setBorder(null);
    final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : ");
    deckLabel.setLabelFor(deckNameTxt);
    final Box deckNamePanel = Box.createHorizontalBox();
    deckNamePanel.add(deckLabel);
    deckNamePanel.add(deckNameTxt);
    deckNamePanel.setMaximumSize(new Dimension(220, 26));

    // Initialize the text field containing the amount to remove
    removeQtyTxt = new JTextField("1");

    // Build the "Remove" button
    removeButton = new JButton(LanguageManager.getString("db_remove"));
    removeButton.setMnemonic('r');
    removeButton.addMouseListener(this);
    removeButton.setEnabled(false);

    // Build the panel containing : "Remove" amount and "Remove" button
    final Box removePanel = Box.createHorizontalBox();
    removePanel.add(removeButton);
    removePanel.add(removeQtyTxt);
    removePanel.setMaximumSize(new Dimension(220, 26));

    // Build the right panel containing : list, available amount, constraints
    final JScrollPane deskListScroller = new JScrollPane(rightList);
    MToolKit.addOverlay(deskListScroller);
    deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    deskListScroller.setMinimumSize(new Dimension(220, 200));
    deskListScroller.setMaximumSize(new Dimension(220, 32000));

    final Box destPanel = Box.createVerticalBox();
    destPanel.add(deckNamePanel);
    destPanel.add(deskListScroller);
    destPanel.add(rightAmount);
    destPanel.add(removePanel);
    destPanel.setMinimumSize(new Dimension(220, 200));
    destPanel.setMaximumSize(new Dimension(220, 32000));

    // Build the panel containing the name of card in picture
    cardPictureNameTxt = new JLabel("<html><i>no selected card</i>");
    final Box cardPictureNamePanel = Box.createHorizontalBox();
    cardPictureNamePanel.add(cardPictureNameTxt);
    cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26));

    // Group the detail panels
    final JPanel viewCard = new JPanel(null);
    viewCard.add(cardPictureNamePanel);
    viewCard.add(CardView.getInstance());
    viewCard.add(tabbedPane);
    viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS));

    final Box mainPanel = Box.createHorizontalBox();
    mainPanel.add(destPanel);
    mainPanel.add(viewCard);

    // Add the main panel
    getContentPane().add(srcPanel, BorderLayout.WEST);
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // Size this frame
    getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
    getRootPane().setMinimumSize(getRootPane().getPreferredSize());
    pack();
}

From source file:org.apache.tika.gui.TikaGUI.java

private void addMenuBar() {
    JMenuBar bar = new JMenuBar();

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    addMenuItem(file, "Open...", "openfile", KeyEvent.VK_O);
    addMenuItem(file, "Open URL...", "openurl", KeyEvent.VK_U);
    file.addSeparator();//w  w w  . ja v  a  2  s  .  com
    addMenuItem(file, "Exit", "exit", KeyEvent.VK_X);
    bar.add(file);

    JMenu view = new JMenu("View");
    view.setMnemonic(KeyEvent.VK_V);
    addMenuItem(view, "Metadata", "metadata", KeyEvent.VK_M);
    addMenuItem(view, "Formatted text", "html", KeyEvent.VK_F);
    addMenuItem(view, "Plain text", "text", KeyEvent.VK_P);
    addMenuItem(view, "Main content", "main", KeyEvent.VK_C);
    addMenuItem(view, "Structured text", "xhtml", KeyEvent.VK_S);
    addMenuItem(view, "Recursive JSON", "json", KeyEvent.VK_J);
    bar.add(view);

    bar.add(Box.createHorizontalGlue());
    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    addMenuItem(help, "About Tika", "about", KeyEvent.VK_A);
    bar.add(help);

    setJMenuBar(bar);
}

From source file:uk.ac.lkl.cram.ui.ModuleFrame.java

/**
 * Creates new form ModuleFrame//  w  w  w  .j av  a 2  s  .  c  o  m
 * @param module the module that this window displays
 * @param file  
 */
public ModuleFrame(final Module module, File file) {
    this.module = module;
    this.moduleFile = file;
    this.setTitle(module.getModuleName());
    initComponents();
    //Add undo mechanism
    undoHandler = new UndoHandler();
    JMenuItem undoMI = editMenu.add(undoHandler.getUndoAction());
    JMenuItem redoMI = editMenu.add(undoHandler.getRedoAction());
    //Listen to the undo handler for when there is something to undo
    undoHandler.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            //We're assuming there's only one property
            //If the new value is true, then there's something to undo
            //And thus the save menu item should be enabled
            Boolean newValue = (Boolean) evt.getNewValue();
            if (moduleFile != null) {
                saveMI.setEnabled(newValue);
            }
        }
    });
    editMenu.addSeparator();
    //Add cut, copy & paste menu items
    JMenuItem cutMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CutAction()));
    cutMI.setText("Cut");
    JMenuItem copyMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CopyAction()));
    copyMI.setText("Copy");
    JMenuItem pasteMI = editMenu.add(new JMenuItem(new DefaultEditorKit.PasteAction()));
    pasteMI.setText("Paste");

    //Listen for changes to the shared selection model
    sharedSelectionModel.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            //Update the menu items
            modifyLineItemMI.setEnabled(evt.getNewValue() != null);
            removeLineItemMI.setEnabled(evt.getNewValue() != null);
        }
    });

    doubleClickListener = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            //If the user double clicks, then treat this as a shortcut to modify the selected line item
            if (e.getClickCount() == 2) {
                modifySelectedLineItem();
            }
        }
    };

    //Set Accelerator keys
    undoMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    redoMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    cutMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    copyMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    pasteMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    newMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    openMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    saveMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    quitMI.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    //Remove quit menu item and separator from file menu on Mac
    if (Utilities.isMac()) {
        fileMenu.remove(quitSeparator);
        fileMenu.remove(quitMI);
    }

    leftTaskPaneContainer.add(createCourseDataPane());
    leftTaskPaneContainer.add(createLineItemPane());
    leftTaskPaneContainer.add(createTutorHoursPane());
    leftTaskPaneContainer.add(createTutorCostPane());
    rightTaskPaneContainer.add(createLearningTypeChartPane());
    rightTaskPaneContainer.add(createLearningExperienceChartPane());
    rightTaskPaneContainer.add(createLearnerFeedbackChartPane());
    rightTaskPaneContainer.add(createHoursChartPane());
    rightTaskPaneContainer.add(createTotalCostsPane());
}

From source file:org.orbisgis.view.sqlconsole.ui.SQLConsolePanel.java

/**
 * Create actions instances/*from www. j av  a  2s  .c o  m*/
 * 
 * Each action is put in the Popup menu and the tool bar
 * Their shortcuts are registered also in the editor
 */
private void initActions() {
    //Execute Action
    executeAction = new DefaultAction(SQLAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Run SQL statements"),
            OrbisGISIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom");
    actions.addAction(executeAction);
    //Clear action
    clearAction = new DefaultAction(SQLAction.A_CLEAR, I18N.tr("Clear"),
            I18N.tr("Erase the content of the editor"), OrbisGISIcon.getIcon("erase"),
            EventHandler.create(ActionListener.class, this, "onClear"), null).setLogicalGroup("custom")
                    .setAfter(SQLAction.A_EXECUTE);
    actions.addAction(clearAction);
    //Find action
    findAction = new DefaultAction(SQLAction.A_SEARCH, I18N.tr("Search.."),
            I18N.tr("Search text in the document"), OrbisGISIcon.getIcon("find"),
            EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"),
            KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK))
                    .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK))
                    .setLogicalGroup("custom");
    actions.addAction(findAction);

    //Quote
    quoteAction = new DefaultAction(SQLAction.A_QUOTE, I18N.tr("Quote"), I18N.tr("Quote selected text"), null,
            EventHandler.create(ActionListener.class, this, "onQuote"),
            KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, InputEvent.SHIFT_DOWN_MASK)).setLogicalGroup("format");
    actions.addAction(quoteAction);
    //unQuote
    unQuoteAction = new DefaultAction(SQLAction.A_UNQUOTE, I18N.tr("Un Quote"),
            I18N.tr("Un Quote selected text"), null,
            EventHandler.create(ActionListener.class, this, "onUnQuote"),
            KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, InputEvent.SHIFT_DOWN_MASK))
                    .setLogicalGroup("format");
    actions.addAction(unQuoteAction);

    //Format SQL
    formatSQLAction = new DefaultAction(SQLAction.A_FORMAT, I18N.tr("Format"), I18N.tr("Format editor content"),
            null, EventHandler.create(ActionListener.class, this, "onFormatCode"),
            KeyStroke.getKeyStroke("alt shift F")).setLogicalGroup("format");
    actions.addAction(formatSQLAction);

    //Save
    saveAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save"),
            I18N.tr("Save the editor content into a file"), OrbisGISIcon.getIcon("save"),
            EventHandler.create(ActionListener.class, this, "onSaveFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom");
    actions.addAction(saveAction);
    //Open action
    actions.addAction(
            new DefaultAction(SQLAction.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"),
                    OrbisGISIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"),
                    KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK))
                            .setLogicalGroup("custom"));
    //ShowHide function list
    actions.addAction(new DefaultAction(SQLAction.A_SQL_LIST, I18N.tr("SQL list"),
            I18N.tr("Show/Hide SQL function list"), OrbisGISIcon.getIcon("builtinfunctionmap"),
            EventHandler.create(ActionListener.class, sqlFunctionsPanel, "switchPanelVisibilityState"), null)
                    .setLogicalGroup("custom"));
}

From source file:electroStaticUI.ElectroStaticUIContainer.java

private void buildFileMenu() {
    //create Exit menu item
    exitItem = new JMenuItem("Exit");
    exitItem.setMnemonic(KeyEvent.VK_X);
    exitItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);/*w w  w .ja  v a 2  s.c o m*/
        }
    });

    //open
    open = new JMenuItem("Open");
    open.setMnemonic(KeyEvent.VK_P);
    open.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fChooser = new JFileChooser();
            int status = fChooser.showSaveDialog(null);
        }
    });

    //close
    close = new JMenuItem("Close");
    close.setMnemonic(KeyEvent.VK_C);

    //export
    export = new JMenuItem("Export");
    export.setMnemonic(KeyEvent.VK_E);
    export.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fChooser = new JFileChooser();
            fChooser.setMultiSelectionEnabled(false);
            fChooser.setAcceptAllFileFilterUsed(false);
            FileNameExtensionFilter svgFilter = new FileNameExtensionFilter("Save Vector Plot(svg)", ".svg");
            FileNameExtensionFilter pngFilter = new FileNameExtensionFilter("Save Voltage Surface Plot(png)",
                    ".png");
            fChooser.addChoosableFileFilter(svgFilter);
            fChooser.addChoosableFileFilter(pngFilter);
            fChooser.setFileFilter(svgFilter);
            int status = fChooser.showSaveDialog(rootPane);
            if (status == JFileChooser.APPROVE_OPTION) {
                if (fChooser.getFileFilter() == svgFilter) {
                    try {
                        saveAsName = fChooser.getSelectedFile().getCanonicalPath();
                        Save.saveChartToSVG(DefaultValues.getChartToSave(), saveAsName, displayPanel.getWidth(),
                                displayPanel.getHeight());
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                } else if (fChooser.getFileFilter() == pngFilter) {
                    try {
                        saveAsName = fChooser.getSelectedFile().getCanonicalPath();
                        Save.saveChart3dToPNG(DefaultValues.get3dChartToSave(), saveAsName);
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            }
        }
    });

    //save
    save = new JMenuItem("Save");
    save.setMnemonic(KeyEvent.VK_S);
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fChooser = new JFileChooser();
            int status = fChooser.showSaveDialog(null);
            if (status == JFileChooser.APPROVE_OPTION) {
                try {
                    System.out.println("Height: " + displayPanel.getWidth());
                    System.out.println("Width: " + displayPanel.getHeight());
                    saveAsName = fChooser.getSelectedFile().getCanonicalPath();
                    Save.saveChartToSVG(DefaultValues.getChartToSave(), saveAsName, displayPanel.getWidth(),
                            displayPanel.getHeight());
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }

        }
    });

    //saveAs
    saveAs = new JMenuItem("Save As");
    saveAs.setMnemonic(KeyEvent.VK_A);
    saveAs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fChooser = new JFileChooser();
            int status = fChooser.showSaveDialog(null);
            if (status == JFileChooser.APPROVE_OPTION)
                try {
                    System.out.println("Height: " + displayPanel.getWidth());
                    System.out.println("Width: " + displayPanel.getHeight());
                    saveAsName = fChooser.getSelectedFile().getCanonicalPath();
                    System.out.println(saveAsName);
                    Save.saveChartToSVG(DefaultValues.getChartToSave(), saveAsName, displayPanel.getWidth(),
                            displayPanel.getHeight());
                } catch (IOException e2) {
                    // TODO Auto-generated catch block
                    e2.printStackTrace();
                }
            try {
                Save.saveChartToSVG(UserInput.getElectricFieldChart(), saveAsName, displayPanel.getWidth(),
                        displayPanel.getHeight());
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //JMenu object for file menu
    fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);

    //fileMenu.add(newFile);
    //fileMenu.add(open);
    //fileMenu.add(close);
    fileMenu.add(export);
    //fileMenu.add(save);
    //fileMenu.add(saveAs);
    fileMenu.add(exitItem);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java

protected void createActions() {
    theActionManager.add("mslevel=ms", FileUtils.defaultThemeManager.getImageIcon("msms"),
            "Change current scan level", -1, "", this);
    theActionManager.add("mslevel=msms", FileUtils.defaultThemeManager.getImageIcon("ms"),
            "Change current scan level", -1, "", this);

    theActionManager.add("updateisotopecurves=true", FileUtils.defaultThemeManager.getImageIcon("isotopesoff"),
            "Automatic computation of isotopic distributions inactive", -1, "", this);
    theActionManager.add("updateisotopecurves=false", FileUtils.defaultThemeManager.getImageIcon("isotopeson"),
            "Automatic computation of isotopic distributions active", -1, "", this);

    theActionManager.add("showallisotopes=true", FileUtils.defaultThemeManager.getImageIcon("ftmodeoff"),
            "FTICR mode inactive", -1, "", this);
    theActionManager.add("showallisotopes=false", FileUtils.defaultThemeManager.getImageIcon("ftmodeon"),
            "FTICR mode active", -1, "", this);

    theActionManager.add("close", FileUtils.defaultThemeManager.getImageIcon("close"), "Close structure",
            KeyEvent.VK_S, "", this);
    theActionManager.add("previous", FileUtils.defaultThemeManager.getImageIcon("previous"),
            "Previous structure", KeyEvent.VK_L, "", this);
    theActionManager.add("next", FileUtils.defaultThemeManager.getImageIcon("next"), "Next structure",
            KeyEvent.VK_N, "", this);

    theActionManager.add("edit", FileUtils.defaultThemeManager.getImageIcon("edit"), "Edit scan data", -1, "",
            this);

    theActionManager.add("new", FileUtils.defaultThemeManager.getImageIcon("new"), "Clear", KeyEvent.VK_N, "",
            this);
    theActionManager.add("openspectra", FileUtils.defaultThemeManager.getImageIcon("openspectra"),
            "Open Spectra", KeyEvent.VK_O, "", this);

    theActionManager.add("print", FileUtils.defaultThemeManager.getImageIcon("print"), "Print...",
            KeyEvent.VK_P, "", this);

    theActionManager.add("addpeaks", FileUtils.defaultThemeManager.getImageIcon("addpeaks"),
            "Add selected peaks to list", -1, "", this);
    theActionManager.add("annotatepeaks", FileUtils.defaultThemeManager.getImageIcon("annotatepeaks"),
            "Find possible annotations for selected peaks", -1, "", this);
    theActionManager.add("baselinecorrection", FileUtils.defaultThemeManager.getImageIcon("baseline"),
            "Baseline correction of current spectrum", -1, "", this);
    theActionManager.add("noisefilter", FileUtils.defaultThemeManager.getImageIcon("noisefilter"),
            "Filter noise in current spectrum", -1, "", this);
    theActionManager.add("centroid", FileUtils.defaultThemeManager.getImageIcon("centroid"),
            "Compute peak centroids", -1, "", this);

    theActionManager.add("arrow", FileUtils.defaultThemeManager.getImageIcon("arrow"), "Activate zoom", -1, "",
            this);
    theActionManager.add("hand", FileUtils.defaultThemeManager.getImageIcon("hand"), "Activate moving", -1, "",
            this);

    theActionManager.add("zoomnone", FileUtils.defaultThemeManager.getImageIcon("zoomnone"), "Reset zoom", -1,
            "", this);
    theActionManager.add("zoomin", FileUtils.defaultThemeManager.getImageIcon("zoomin"), "Zoom in", -1, "",
            this);
    theActionManager.add("zoomout", FileUtils.defaultThemeManager.getImageIcon("zoomout"), "Zoom out", -1, "",
            this);
}

From source file:com.lfv.lanzius.server.LanziusServer.java

public void init() {

    log.info(Config.VERSION + "\n");

    docVersion = 0;//from w  w  w.j a v a 2  s .co m

    frame = new JFrame(Config.TITLE + " - Server Control Panel");

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            actionPerformed(new ActionEvent(itemExit, 0, null));
        }
    });

    // Create graphical terminal view
    panel = new WorkspacePanel(this);
    frame.getContentPane().add(panel);

    // Create a menu bar
    JMenuBar menuBar = new JMenuBar();

    // FILE
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    // Load configuration
    itemLoadConfig = new JMenuItem("Load configuration...");
    itemLoadConfig.addActionListener(this);
    fileMenu.add(itemLoadConfig);
    // Load terminal setup
    itemLoadExercise = new JMenuItem("Load exercise...");
    itemLoadExercise.addActionListener(this);
    fileMenu.add(itemLoadExercise);
    fileMenu.addSeparator();
    // Exit
    itemExit = new JMenuItem("Exit");
    itemExit.addActionListener(this);
    fileMenu.add(itemExit);
    menuBar.add(fileMenu);

    // SERVER
    JMenu serverMenu = new JMenu("Server");
    serverMenu.setMnemonic(KeyEvent.VK_S);
    // Start
    itemServerStart = new JMenuItem("Start");
    itemServerStart.addActionListener(this);
    serverMenu.add(itemServerStart);
    // Stop
    itemServerStop = new JMenuItem("Stop");
    itemServerStop.addActionListener(this);
    serverMenu.add(itemServerStop);
    // Restart
    itemServerRestart = new JMenuItem("Restart");
    itemServerRestart.addActionListener(this);
    itemServerRestart.setEnabled(false);
    serverMenu.add(itemServerRestart);
    // Monitor network connection
    itemServerMonitor = new JCheckBoxMenuItem("Monitor network");
    itemServerMonitor.addActionListener(this);
    itemServerMonitor.setState(false);
    serverMenu.add(itemServerMonitor);
    menuBar.add(serverMenu);

    // TERMINAL
    JMenu terminalMenu = new JMenu("Terminal");
    terminalMenu.setMnemonic(KeyEvent.VK_T);
    itemTerminalLink = new JMenuItem("Link...");
    itemTerminalLink.addActionListener(this);
    terminalMenu.add(itemTerminalLink);
    itemTerminalUnlink = new JMenuItem("Unlink...");
    itemTerminalUnlink.addActionListener(this);
    terminalMenu.add(itemTerminalUnlink);
    itemTerminalUnlinkAll = new JMenuItem("Unlink All");
    itemTerminalUnlinkAll.addActionListener(this);
    terminalMenu.add(itemTerminalUnlinkAll);
    itemTerminalSwap = new JMenuItem("Swap...");
    itemTerminalSwap.addActionListener(this);
    terminalMenu.add(itemTerminalSwap);
    menuBar.add(terminalMenu);

    // GROUP
    JMenu groupMenu = new JMenu("Group");
    groupMenu.setMnemonic(KeyEvent.VK_G);
    itemGroupStart = new JMenuItem("Start...");
    itemGroupStart.addActionListener(this);
    groupMenu.add(itemGroupStart);
    itemGroupPause = new JMenuItem("Pause...");
    itemGroupPause.addActionListener(this);
    groupMenu.add(itemGroupPause);
    itemGroupStop = new JMenuItem("Stop...");
    itemGroupStop.addActionListener(this);
    groupMenu.add(itemGroupStop);
    menuBar.add(groupMenu);

    frame.setJMenuBar(menuBar);

    GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Rectangle maximumWindowBounds = graphicsEnvironment.getMaximumWindowBounds();

    if (Config.SERVER_SIZE_FULLSCREEN) {
        maximumWindowBounds.setLocation(0, 0);
        maximumWindowBounds.setSize(Toolkit.getDefaultToolkit().getScreenSize());
        frame.setResizable(false);
        frame.setUndecorated(true);
    } else if (Config.SERVER_SIZE_100P_WINDOW) {
        // Fixes a bug in linux using gnome. With the line below the upper and
        // lower bars are respected
        maximumWindowBounds.height -= 1;
    } else if (Config.SERVER_SIZE_75P_WINDOW) {
        maximumWindowBounds.width *= 0.75;
        maximumWindowBounds.height *= 0.75;
    } else if (Config.SERVER_SIZE_50P_WINDOW) {
        maximumWindowBounds.width /= 2;
        maximumWindowBounds.height /= 2;
    }

    frame.setBounds(maximumWindowBounds);
    frame.setVisible(true);

    log.info("Starting control panel");

    // Autostart for debugging
    if (Config.SERVER_AUTOLOAD_CONFIGURATION != null)
        actionPerformed(new ActionEvent(itemLoadConfig, 0, null));

    if (Config.SERVER_AUTOSTART_SERVER)
        actionPerformed(new ActionEvent(itemServerStart, 0, null));

    if (Config.SERVER_AUTOLOAD_EXERCISE != null)
        actionPerformed(new ActionEvent(itemLoadExercise, 0, null));

    if (Config.SERVER_AUTOSTART_GROUP > 0)
        actionPerformed(new ActionEvent(itemGroupStart, 0, null));

    try {
        // Read the property files
        serverProperties = new Properties();
        serverProperties.loadFromXML(new FileInputStream("data/properties/serverproperties.xml"));
        int rcPort = Integer.parseInt(serverProperties.getProperty("RemoteControlPort", "0"));
        if (rcPort > 0) {
            groupRemoteControlListener(rcPort);
        }
        isaPeriod = Integer.parseInt(serverProperties.getProperty("ISAPeriod", "60"));
        isaNumChoices = Integer.parseInt(serverProperties.getProperty("ISANumChoices", "6"));
        for (int i = 0; i < 9; i++) {
            String tag = "ISAKeyText" + Integer.toString(i);
            String def_val = Integer.toString(i + 1);
            isakeytext[i] = serverProperties.getProperty(tag, def_val);
        }
        isaExtendedMode = serverProperties.getProperty("ISAExtendedMode", "false").equalsIgnoreCase("true");
    } catch (Exception e) {
        log.error("Unable to start remote control listener");
        log.error(e.getMessage());
    }
    isaClients = new HashSet<Integer>();
}

From source file:org.orbisgis.r.RConsolePanel.java

/**
 * Create actions instances//  w w  w .  java  2s. c  o  m
 *
 * Each action is put in the Popup menu and the tool bar Their shortcuts are
 * registered also in the editor
 */
private void initActions() {
    //Execute action
    executeAction = new DefaultAction(RConsoleActions.A_EXECUTE, I18N.tr("Execute"),
            I18N.tr("Execute the R script"), RIcon.getIcon("execute"),
            EventHandler.create(ActionListener.class, this, "onExecute"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(executeAction);

    //Execute Selected SQL
    executeSelectedAction = new DefaultAction(RConsoleActions.A_EXECUTE_SELECTION, I18N.tr("Execute selected"),
            I18N.tr("Run selected code"), RIcon.getIcon("execute_selection"),
            EventHandler.create(ActionListener.class, this, "onExecuteSelected"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom")
                    .setAfter(RConsoleActions.A_EXECUTE);
    actions.addAction(executeSelectedAction);

    //Clear action
    clearAction = new DefaultAction(RConsoleActions.A_CLEAR, I18N.tr("Clear"),
            I18N.tr("Erase the content of the editor"), RIcon.getIcon("erase"),
            EventHandler.create(ActionListener.class, this, "onClear"), null);
    actions.addAction(clearAction);

    //Open action
    actions.addAction(
            new DefaultAction(RConsoleActions.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"),
                    RIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"),
                    KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)));
    //Save
    saveAction = new DefaultAction(RConsoleActions.A_SAVE, I18N.tr("Save"),
            I18N.tr("Save the editor content into a file"), RIcon.getIcon("save"),
            EventHandler.create(ActionListener.class, this, "onSaveFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(saveAction);
    // Save As
    saveAsAction = new DefaultAction(RConsoleActions.A_SAVE, I18N.tr("Save As"),
            I18N.tr("Save the editor content into a new file"), RIcon.getIcon("page_white_save"),
            EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"),
            KeyStroke.getKeyStroke("ctrl maj s"));
    actions.addAction(saveAsAction);
    //Find action
    findAction = new DefaultAction(RConsoleActions.A_SEARCH, I18N.tr("Search.."),
            I18N.tr("Search text in the document"), RIcon.getIcon("find"),
            EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"),
            KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK))
                    .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(findAction);

    // Comment/Uncomment
    commentAction = new DefaultAction(RConsoleActions.A_COMMENT, I18N.tr("(Un)comment"),
            I18N.tr("(Un)comment the selected text"), null,
            EventHandler.create(ActionListener.class, this, "onComment"), KeyStroke.getKeyStroke("alt C"))
                    .setLogicalGroup("format");
    actions.addAction(commentAction);

}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java

private void createActions() {

    //file/*from   w w w  .j  a  v a  2s  .  co m*/
    theActionManager.add("print", FileUtils.defaultThemeManager.getImageIcon("print"), "Print...",
            KeyEvent.VK_P, "ctrl P", this);

    //edit

    theActionManager.add("undo", FileUtils.defaultThemeManager.getImageIcon("undo"), "Undo", KeyEvent.VK_U,
            "ctrl Z", this);
    theActionManager.add("redo", FileUtils.defaultThemeManager.getImageIcon("redo"), "Redo", KeyEvent.VK_R,
            "ctrl Y", this);

    theActionManager.add("cut", FileUtils.defaultThemeManager.getImageIcon("cut"), "Cut", KeyEvent.VK_T,
            "ctrl X", this);
    theActionManager.add("copy", FileUtils.defaultThemeManager.getImageIcon("copy"), "Copy", KeyEvent.VK_C,
            "ctrl C", this);
    theActionManager.add("delete", FileUtils.defaultThemeManager.getImageIcon("delete"), "Delete",
            KeyEvent.VK_DELETE, "", this);
    theActionManager.add("screenshot", FileUtils.defaultThemeManager.getImageIcon("screenshot"), "Screenshot",
            KeyEvent.VK_PRINTSCREEN, "PRINTSCREEN", this);

    theActionManager.add("selectall", FileUtils.defaultThemeManager.getImageIcon("selectall"), "Select all",
            KeyEvent.VK_A, "ctrl A", this);
    theActionManager.add("selectnone", FileUtils.defaultThemeManager.getImageIcon("selectnone"), "Select none",
            KeyEvent.VK_E, "ESCAPE", this);

    theActionManager.add("enlarge", FileUtils.defaultThemeManager.getImageIcon("enlarge"),
            "Enlarge selected structures", -1, "", this);
    theActionManager.add("resetsize", FileUtils.defaultThemeManager.getImageIcon("resetsize"),
            "Reset size of selected structures to default value", -1, "", this);
    theActionManager.add("shrink", FileUtils.defaultThemeManager.getImageIcon("shrink"),
            "Shrink selected structures", -1, "", this);

    theActionManager.add("ungroup", FileUtils.defaultThemeManager.getImageIcon("ungroup"),
            "Ungroup selected structures", -1, "", this);
    theActionManager.add("group", FileUtils.defaultThemeManager.getImageIcon("group"),
            "Group selected structures", -1, "", this);

    theActionManager.add("placestructures", FileUtils.defaultThemeManager.getImageIcon("placestructures"),
            "Automatic place all structures", -1, "", this);

    // view
    theActionManager.add("zoomnone", FileUtils.defaultThemeManager.getImageIcon("zoomnone"), "Reset zoom", -1,
            "", this);
    theActionManager.add("zoomin", FileUtils.defaultThemeManager.getImageIcon("zoomin"), "Zoom in", -1, "",
            this);
    theActionManager.add("zoomout", FileUtils.defaultThemeManager.getImageIcon("zoomout"), "Zoom out", -1, "",
            this);

    theActionManager.add("notation=" + GraphicOptions.NOTATION_CFG,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG notation", KeyEvent.VK_C, "", this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGBW,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG black and white notation", KeyEvent.VK_B, "",
            this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGLINK,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG with linkage placement notation",
            KeyEvent.VK_L, "", this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_UOXF,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "UOXF notation", KeyEvent.VK_O, "", this);
    theActionManager.add("notation=" + GraphicOptions.NOTATION_TEXT,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "Text only notation", KeyEvent.VK_T, "", this);

    theActionManager.add("display=" + GraphicOptions.DISPLAY_COMPACT,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "compact view", KeyEvent.VK_O, "", this);
    theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMAL,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view", KeyEvent.VK_N, "", this);
    theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMALINFO,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view with linkage info", KeyEvent.VK_I,
            "", this);
    theActionManager.add("display=" + GraphicOptions.DISPLAY_CUSTOM,
            ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "custom view with user settings", KeyEvent.VK_K,
            "", this);

    theActionManager.add("orientation", getOrientationIcon(), "Change orientation", -1, "", this);

    theActionManager.add("displaysettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY),
            "Change structure display settings", KeyEvent.VK_S, "", this);
    theActionManager.add("reportsettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY),
            "Change report display settings", KeyEvent.VK_R, "", this);
}