Example usage for java.awt.event KeyEvent VK_F5

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

Introduction

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

Prototype

int VK_F5

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

Click Source Link

Document

Constant for the F5 function key.

Usage

From source file:net.sf.jhylafax.JHylaFAX.java

private void initializeShortCuts() {
    sendActionShortcut = new ActionShortcut(sendAction);
    sendActionShortcut.setKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));

    updateStatusActionShortcut = new ActionShortcut(updateStatusAction);
    updateStatusActionShortcut.setKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
}

From source file:org.squidy.nodes.GestureRecognizerShake.java

public void gestureReceived(GestureEvent event) {
    // DataGesture dataGesture = null;
    DataString dataString = null;//from  w w  w.  j  a va 2s. c o  m

    DataKey dataKeyUp = null;
    DataKey dataKeyDown = null;
    DataButton dataButtonUp = null;
    DataButton dataButtonDown = null;
    if (event.isValid() && event.getProbability() > 0.8) {
        if (gesturesLoaded.containsKey(event.getId())) {
            System.out.println("New Gesture Event \"" + gesturesLoaded.get(event.getId()).getGesture()
                    + "\" with ID " + event.getId() + " and Probability " + event.getProbability()
                    + " from Source " + event.getSource());
            String gesture = gesturesLoaded.get(event.getId()).getGesture();
            if (gesture.contains("right")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_RIGHT, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_RIGHT, false);
                dataButtonUp = new DataButton(GestureRecognizerShake.class, MouseEvent.BUTTON1, true);
                dataButtonUp = new DataButton(GestureRecognizerShake.class, MouseEvent.BUTTON1, false);
            } else if (gesture.contains("left")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_LEFT, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_LEFT, false);
            } else if (gesture.contains("circle")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_F5, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_F5, false);
            }
            dataString = new DataString(GestureRecognizerShake.class,
                    gesturesLoaded.get(event.getId()).getGesture());
        } else {
            LOG.info("New Gesture Event (not loaded) with ID " + event.getId() + " and Probability "
                    + event.getProbability() + " from Source " + event.getSource());

            dataString = new DataString(GestureRecognizerShake.class,
                    gesturesLoaded.get(event.getId()).getGesture());
        }
        dataString.setAttribute(DataConstant.SESSION_ID, event.getId());

        if (dataString != null)
            publish(dataString);
        if (dataKeyUp != null)
            publish(dataKeyUp);
        if (dataKeyDown != null)
            publish(dataKeyDown);
    }
}

From source file:org.executequery.gui.editor.QueryEditorPopupMenu.java

private JMenuItem createExecuteMenuItem() {
    JMenuItem menuItem = MenuItemFactory.createMenuItem(action());
    menuItem.setText("Execute");
    menuItem.setActionCommand("execute");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
    executeActionButtons().add(menuItem);
    return menuItem;
}

From source file:es.darkhogg.hazelnutt.EditorFrame.java

private void initializeGui() {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    setBounds(100, 100, 640, 480);//from   w  ww .  j av  a  2 s  .c  om

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            actionExit();
        }
    });

    fileChooser = new JFileChooser();
    //fileChooser.setFileFilter( hlfFileFilter );

    hlfFileChooser = new JFileChooser();
    hlfFileChooser.setFileFilter(hlfFileFilter);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('F');
    menuBar.add(mnFile);

    menuLoadRom = new JMenuItem("Load ROM...");
    menuLoadRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
    menuLoadRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionOpenRom(null);
        }
    });
    menuLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png")));
    menuLoadRom.setMnemonic('O');
    mnFile.add(menuLoadRom);

    menuSaveRom = new JMenuItem("Save ROM");
    menuSaveRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveRom();
        }
    });
    menuSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png")));
    menuSaveRom.setMnemonic('S');
    menuSaveRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
    mnFile.add(menuSaveRom);

    menuSaveRomAs = new JMenuItem("Save ROM As...");
    menuSaveRomAs.setMnemonic('a');
    menuSaveRomAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));
    menuSaveRomAs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveRomAs();
        }
    });
    menuSaveRomAs
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_as.png")));
    mnFile.add(menuSaveRomAs);

    mnFile.addSeparator();

    menuLoadLevel = new JMenuItem("Load Level...");
    menuLoadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
    menuLoadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionLoadLevel();
        }
    });
    menuLoadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png")));
    menuLoadLevel.setMnemonic('L');
    mnFile.add(menuLoadLevel);

    menuReloadLevel = new JMenuItem("Reload Level");
    menuReloadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0));
    menuReloadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionReloadLevel();
        }
    });
    menuReloadLevel.setMnemonic('R');
    menuReloadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png")));
    mnFile.add(menuReloadLevel);

    menuSaveLevel = new JMenuItem("Save Level");
    menuSaveLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0));
    menuSaveLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveLevel();
        }
    });
    menuSaveLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png")));
    menuSaveLevel.setMnemonic('v');

    mnFile.add(menuSaveLevel);

    //*
    mnFile.addSeparator();

    menuImportLevel = new JMenuItem("Import Level...");
    menuImportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    menuImportLevel.setMnemonic('i');
    menuImportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionImportLevel();
        }
    });
    menuImportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png")));
    mnFile.add(menuImportLevel);

    menuExportLevel = new JMenuItem("Export Level...");
    menuExportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
    menuExportLevel.setMnemonic('e');
    menuExportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionExportLevel();
        }
    });
    menuExportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png")));
    mnFile.add(menuExportLevel);
    //*/

    mnFile.addSeparator();

    menuExit = new JMenuItem("Exit");
    menuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
    menuExit.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_exit.png")));
    menuExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            actionExit();
        }
    });

    menuRecentFiles = new JMenu("Recent Files...");
    mnFile.add(menuRecentFiles);

    mnFile.addSeparator();
    menuExit.setMnemonic('X');
    mnFile.add(menuExit);

    JMenu mnEdit = new JMenu("Edit");
    mnEdit.setMnemonic('E');
    menuBar.add(mnEdit);

    menuViewSpawn = new JCheckBoxMenuItem("View Spawn Point");
    menuViewSpawn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0));
    menuViewSpawn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });

    menuClearLevel = new JMenuItem("Clear Level");
    menuClearLevel.setMnemonic('c');
    menuClearLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
    menuClearLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionClearLevel();
        }
    });
    menuClearLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png")));
    mnEdit.add(menuClearLevel);

    mnEdit.addSeparator();

    menuViewSpawn
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png")));
    menuViewSpawn.setMnemonic('S');
    menuViewSpawn.setSelected(true);
    mnEdit.add(menuViewSpawn);

    menuViewItems = new JCheckBoxMenuItem("View Items");
    menuViewItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0));
    menuViewItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewItems.setSelected(true);
    menuViewItems
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png")));
    menuViewItems.setMnemonic('I');
    mnEdit.add(menuViewItems);

    menuViewDoorItems = new JCheckBoxMenuItem("View Door Items");
    menuViewDoorItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0));
    menuViewDoorItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewDoorItems.setSelected(true);
    menuViewDoorItems.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png")));
    menuViewDoorItems.setMnemonic('D');
    mnEdit.add(menuViewDoorItems);

    menuViewEnemies = new JCheckBoxMenuItem("View Enemies");
    menuViewEnemies.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0));
    menuViewEnemies.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewEnemies.setSelected(true);
    menuViewEnemies
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png")));
    menuViewEnemies.setMnemonic('E');
    mnEdit.add(menuViewEnemies);

    menuViewTypes = new JCheckBoxMenuItem("View Combo Types");
    menuViewTypes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0));
    menuViewTypes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewTypes.setSelected(true);
    menuViewTypes.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png")));
    menuViewTypes.setMnemonic('C');
    mnEdit.add(menuViewTypes);

    mnEdit.addSeparator();

    scaleMenuItem = new JCheckBoxMenuItem("Scale Level Display");
    scaleMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0));
    scaleMenuItem.setMnemonic('l');
    scaleMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionScale(false);
        }
    });
    scaleMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png")));
    mnEdit.add(scaleMenuItem);

    gridMenuItem = new JCheckBoxMenuItem("Display grid");
    gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0));
    gridMenuItem.setMnemonic('G');
    gridMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionGrid(false);
        }
    });
    gridMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png")));
    mnEdit.add(gridMenuItem);

    //mnEdit.addSeparator();

    mntmPreferences = new JMenuItem("Preferences...");
    mntmPreferences.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionPreferences();
        }
    });
    mntmPreferences.setMnemonic('P');
    mntmPreferences.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_preferences.png")));
    //mnEdit.add(mntmPreferences);

    mnHelp = new JMenu("Help");
    mnHelp.setMnemonic('H');
    menuBar.add(mnHelp);

    mntmCheckUpdates = new JMenuItem("Check for Updates...");
    mntmCheckUpdates.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK));
    mntmCheckUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionCheckUpdates();
        }
    });
    mntmCheckUpdates.setMnemonic('c');
    mntmCheckUpdates
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_update.png")));
    mnHelp.add(mntmCheckUpdates);

    mntmAbout = new JMenuItem("Readme...");
    mntmAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    mntmAbout.setMnemonic('r');
    mntmAbout.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/about.png")));
    mntmAbout.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionAbout();
        }
    });
    mnHelp.addSeparator();
    mnHelp.add(mntmAbout);

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    contentPane.add(toolBar, BorderLayout.NORTH);

    barLoadRom = new JButton("");
    barLoadRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionOpenRom(null);
        }
    });
    barLoadRom.setToolTipText("Open");
    barLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png")));
    toolBar.add(barLoadRom);

    barSaveRom = new JButton("");
    barSaveRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveRom();
        }
    });
    barSaveRom.setToolTipText("Save");
    barSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png")));
    toolBar.add(barSaveRom);

    toolBar.addSeparator();

    barImportLevel = new JButton("");
    barImportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionImportLevel();
        }
    });
    barImportLevel.setToolTipText("Import Level");
    barImportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png")));
    toolBar.add(barImportLevel);

    barExportLevel = new JButton("");
    barExportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionExportLevel();
        }
    });
    barExportLevel.setToolTipText("Export Level");
    barExportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png")));
    toolBar.add(barExportLevel);

    toolBar.addSeparator();

    barLoadLevel = new JButton("");
    barLoadLevel.setToolTipText("Load Level");
    barLoadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionLoadLevel();
        }
    });
    barLoadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png")));
    toolBar.add(barLoadLevel);

    barReloadLevel = new JButton("");
    barReloadLevel.setToolTipText("Reload Current Level");
    barReloadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionReloadLevel();
        }
    });
    barReloadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png")));
    toolBar.add(barReloadLevel);

    barSaveLevel = new JButton("");
    barSaveLevel.setToolTipText("Save Level");
    barSaveLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveLevel();
        }
    });
    barSaveLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png")));
    toolBar.add(barSaveLevel);

    toolBar.addSeparator();

    barViewItems = new JToggleButton("");
    barViewItems.setToolTipText("Toggle View Items");
    barViewItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });

    barViewSpawn = new JToggleButton("");
    barViewSpawn.setToolTipText("Toggle View Spawn");
    barViewSpawn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });

    barClearLevel = new JButton("");
    barClearLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionClearLevel();
        }
    });
    barClearLevel.setToolTipText("Clear Level");
    barClearLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png")));
    toolBar.add(barClearLevel);

    toolBar.addSeparator();

    barViewSpawn.setSelected(true);
    barViewSpawn.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png")));
    toolBar.add(barViewSpawn);
    barViewItems.setSelected(true);
    barViewItems.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png")));
    toolBar.add(barViewItems);

    barViewDoorItems = new JToggleButton("");
    barViewDoorItems.setToolTipText("Toggle View Door Items");
    barViewDoorItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });
    barViewDoorItems.setSelected(true);
    barViewDoorItems.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png")));
    toolBar.add(barViewDoorItems);

    barViewEnemies = new JToggleButton("");
    barViewEnemies.setToolTipText("toggle View Enemies");
    barViewEnemies.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });
    barViewEnemies.setSelected(true);
    barViewEnemies
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png")));
    toolBar.add(barViewEnemies);

    barViewTypes = new JToggleButton("");
    barViewTypes.setToolTipText("Toggle view Combo Help");
    barViewTypes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });
    barViewTypes.setSelected(true);
    barViewTypes.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png")));
    toolBar.add(barViewTypes);

    barViewSpawn.setSelected(config.getBoolean("Hazelnutt.gui.viewSpawn", true));
    barViewItems.setSelected(config.getBoolean("Hazelnutt.gui.viewItems", true));
    barViewDoorItems.setSelected(config.getBoolean("Hazelnutt.gui.viewDoorItems", true));
    barViewEnemies.setSelected(config.getBoolean("Hazelnutt.gui.viewEnemies", true));
    barViewTypes.setSelected(config.getBoolean("Hazelnutt.gui.viewHelp", true));

    panel = new JPanel();
    contentPane.add(panel, BorderLayout.EAST);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    selectorPanel = new SelectorPanel();
    selectorPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            "Combo & Entity Selector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    panel.add(selectorPanel);

    propertiesPanel = new PropertiesPanel(null);
    propertiesPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level Properties",
            TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    panel.add(propertiesPanel);

    toolBar.addSeparator();

    scaleButton = new JToggleButton("");
    scaleButton.setToolTipText("Toggle Scale Display");
    scaleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionScale(true);
        }
    });
    scaleButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png")));
    toolBar.add(scaleButton);

    scaleButton.setSelected(config.getBoolean("Hazelnutt.gui.scaled", false));

    gridButton = new JToggleButton("");
    gridButton.setToolTipText("Display Grid");
    gridButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionGrid(true);
        }
    });
    gridButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png")));
    toolBar.add(gridButton);

    gridButton.setSelected(config.getBoolean("Hazelnutt.gui.grid", false));

    Component horizontalGlue = Box.createHorizontalGlue();
    toolBar.add(horizontalGlue);

    Component verticalGlue = Box.createVerticalGlue();
    panel.add(verticalGlue);

    levelWrapper = new JPanel();
    levelWrapper.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level",
            TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    contentPane.add(levelWrapper, BorderLayout.CENTER);
    levelWrapper.setLayout(new BorderLayout(0, 0));

    scrollPane = new JScrollPane();
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
    levelWrapper.add(scrollPane);

    levelDisplay = new LevelDisplay();
    levelDisplay.addEditListener(new EditListener() {
        @Override
        public void leftPressed(int x, int y) {
            SelectionType st = selectorPanel.getSelectionType();
            Object so = selectorPanel.getSelectedObject();

            if (st == SelectionType.COMBO) {
                paintComboAt(x, y, ((Byte) so).byteValue());
            } else if (st == SelectionType.SPAWN) {
                selectedLevel.getRomLevel().setSpawn(new IntVector(x, y));

                levelHasChanged = true;
            } else if (st == SelectionType.ITEM) {
                Item ent = new Item((ItemType) so, x, y);
                EntityCollection<Item> ents = selectedLevel.getRomLevel().getItems();
                for (Iterator<Item> it = ents.iterator(); it.hasNext();) {
                    Item item = it.next();
                    if (item.getX() == x && item.getY() == y) {
                        it.remove();
                    }
                }
                if (ents.size() <= ents.maxSize()) {
                    ents.add(ent);
                    levelHasChanged = true;
                }
            } else if (st == SelectionType.DOOR_ITEM) {
                Item ent = new Item((ItemType) so, x, y);
                EntityCollection<Item> ents = selectedLevel.getRomLevel().getDoorItems();
                for (Iterator<Item> it = ents.iterator(); it.hasNext();) {
                    Item item = it.next();
                    if (item.getX() == x && item.getY() == y) {
                        it.remove();
                    }
                }
                if (ents.size() <= ents.maxSize()) {
                    ents.add(ent);
                    levelHasChanged = true;
                }
            } else if (st == SelectionType.ENEMY) {
                Enemy ent = new Enemy((EnemyType) so, x, y);
                EntityCollection<Enemy> ents = selectedLevel.getRomLevel().getEnemies();
                for (Iterator<Enemy> it = ents.iterator(); it.hasNext();) {
                    Enemy enem = it.next();
                    if (enem.getX() == x && enem.getY() == y) {
                        it.remove();
                    }
                }
                if (ents.size() <= ents.maxSize()) {
                    ents.add(ent);
                    levelHasChanged = true;
                }
            }

            updateTitle();
            levelDisplay.repaint();
            levelHasChanged = true;
        }

        @Override
        public void centerPressed(int x, int y) {
            selectorPanel.forceComboSelection(selectedLevel.getRomLevel().getData()[x][y]);
        }

        @Override
        public void rightPressed(int x, int y) {
            deleteVisibleEntitiesAt(x, y);
        }

        @Override
        public void leftDragged(int x, int y) {
            if (selectorPanel.getSelectionType() == SelectionType.COMBO) {
                paintComboAt(x, y, ((Byte) selectorPanel.getSelectedObject()).byteValue());
            }
        }

        @Override
        public void centerDragged(int x, int y) {
            // Nothing to de here
        }

        @Override
        public void rightDragged(int x, int y) {
            deleteVisibleEntitiesAt(x, y);
        }

        // Utility methods
        /*private void selectComboAt ( int x, int y ) {
                   
        }/**/
        private void paintComboAt(int x, int y, byte value) {
            selectedLevel.getRomLevel().getData()[x][y] = value;
            levelHasChanged = true;

            updateTitle();
            levelDisplay.repaint();
        }

        private void deleteVisibleEntitiesAt(int x, int y) {
            Collection<Item> items = selectedLevel.getRomLevel().getItems();
            Collection<Item> doorItems = selectedLevel.getRomLevel().getDoorItems();
            Collection<Enemy> enemies = selectedLevel.getRomLevel().getEnemies();

            if (barViewItems.isSelected()) {
                for (Iterator<Item> it = items.iterator(); it.hasNext();) {
                    Item item = it.next();
                    if (item.getX() == x && item.getY() == y) {
                        it.remove();
                        levelHasChanged = true;
                    }
                }
            }

            if (barViewDoorItems.isSelected()) {
                for (Iterator<Item> it = doorItems.iterator(); it.hasNext();) {
                    Item doorItem = it.next();
                    if (doorItem.getX() == x && doorItem.getY() == y) {
                        it.remove();
                        levelHasChanged = true;
                    }
                }
            }

            if (barViewEnemies.isSelected()) {
                for (Iterator<Enemy> it = enemies.iterator(); it.hasNext();) {
                    Enemy enem = it.next();
                    if (enem.getX() == x && enem.getY() == y) {
                        it.remove();
                        levelHasChanged = true;
                    }
                }
            }

            updateTitle();
            levelDisplay.repaint();
        }
    });
    scrollPane.setViewportView(levelDisplay);

    updateTitle();
    actionToggle(true);
    actionScale(true);
    actionGrid(true);
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/witch_hazel_big.png")));
    setRomFeaturesEnabled(false);
    setLevelFeaturesEnabled(false);

    if (config.getBoolean("Hazelnutt.gui.maximum", false)) {
        setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
    } else {
        int x = config.getInt("Hazelnutt.gui.location.x", Integer.MIN_VALUE);
        int y = config.getInt("Hazelnutt.gui.location.y", Integer.MIN_VALUE);
        int w = config.getInt("Hazelnutt.gui.size.width", Integer.MIN_VALUE);
        int h = config.getInt("Hazelnutt.gui.size.height", Integer.MIN_VALUE);

        if (x == Integer.MIN_VALUE || x == Integer.MIN_VALUE || w == Integer.MIN_VALUE
                || h == Integer.MIN_VALUE) {
            setLocationRelativeTo(null);
        } else {
            setLocation(x, y);
            setSize(w, h);
        }
    }

    propertiesPanel.addApplyListener(new PropertiesPanel.ApplyListener() {
        @Override
        public void apply() {
            levelHasChanged = true;
            updateTitle();
            updateDisplay();
        }
    });

    if (config.containsKey("Hazelnutt.gui.lastDirectory")) {
        File lastDir = new File(config.getString("Hazelnutt.gui.lastDirectory"));
        if (lastDir.exists() && lastDir.isDirectory()) {
            //logger.debug( "Resetting the last directory: '" + lastDir + "'" );
            fileChooser.setCurrentDirectory(lastDir);
        }
    }

    // Configure the PgUp and PgDn shortcuts
    InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PgUp");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PgDn");
    ActionMap am = contentPane.getActionMap();
    am.put("PgUp", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            actionLevelUp();
        }
    });
    am.put("PgDn", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            actionLevelDown();
        }
    });

    // Get the recent files
    recentFiles = new LinkedList<String>(Arrays.asList(config.getStringArray("Hazelnutt.gui.recentFiles")));
    updateRecentFiles();

}

From source file:org.datavyu.views.DatavyuView.java

/**
 * Constructor./*from   w  w  w .  j a  v  a  2 s . com*/
 *
 * @param app
 *            The SingleFrameApplication that invoked this main FrameView.
 */
public DatavyuView(final SingleFrameApplication app) {
    super(app);

    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();

    manager.addKeyEventDispatcher(new KeyEventDispatcher() {

        /**
         * Dispatches the keystroke to the correct action.
         *
         * @param evt The event that triggered this action.
         * @return true if the KeyboardFocusManager should take no further
         * action with regard to the KeyEvent; false otherwise.
         */
        @Override
        public boolean dispatchKeyEvent(final KeyEvent evt) {

            // Pass the keyevent onto the keyswitchboard so that it can
            // route it to the correct action.
            //                    spreadsheetMenuSelected(null);

            return Datavyu.getApplication().dispatchKeyEvent(evt);
        }
    });

    // generated GUI builder code
    initComponents();

    // BugzID:492 - Set the shortcut for new cell, so a keystroke that won't
    // get confused for the "carriage return". The shortcut for new cells
    // is handled in Datavyu.java
    newCellMenuItem.setAccelerator(KeyStroke.getKeyStroke('\u21A9'));

    // BugzID:521 + 468 - Define accelerator keys based on Operating system.
    int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    weakTemporalOrderMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, keyMask));

    strongTemporalOrderMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.SHIFT_MASK | keyMask));

    // Set zoom in to keyMask + '+'
    zoomInMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, keyMask));

    // Set zoom out to keyMask + '-'
    zoomOutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, keyMask));

    // Set reset zoom to keyMask + '0'
    resetZoomMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, keyMask));

    // Set the save accelerator to keyMask + 'S'
    saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask));

    // Set the save as accelerator to keyMask + shift + 'S'
    saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, keyMask | InputEvent.SHIFT_MASK));

    // Set the open accelerator to keyMask + 'o';
    openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, keyMask));

    // Set the new accelerator to keyMask + 'N';
    newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, keyMask));

    // Set the new accelerator to keyMask + 'L';
    newCellLeftMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, keyMask));

    // Set the new accelerator to keyMask + 'R';
    newCellRightMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, keyMask));

    // Set the show spreadsheet accelrator to F5.
    showSpreadsheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));

    // Set the undo accelerator to keyMask + 'Z';
    undoSpreadSheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, keyMask));

    // Set the redo accelerator to keyMask + 'Y'
    redoSpreadSheetMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, keyMask));

    if (panel != null) {
        panel.deregisterListeners();
        panel.removeFileDropEventListener(this);
    }

    panel = new SpreadsheetPanel(Datavyu.getProjectController().getDB(), null);
    panel.registerListeners();
    panel.addFileDropEventListener(this);
    setComponent(panel);

    System.out.println(getComponent());

    // initialize the undo/redo system
    spreadsheetUndoManager = new SpreadsheetUndoManager();
    undoSupport = new UndoableEditSupport();
    undoSupport.addUndoableEditListener(new UndoAdapter());
    refreshUndoRedo();
    //////

    //Jakrabbit Menu
    pushMenuItem.setVisible(false);
    pullMenuItem.setVisible(false);
    jSeparator10.setVisible(false);

}

From source file:org.slage.tests.ImageTest.java

/** Hard-code a pause key click */
public void makePauseHandler() {
    addKeyHandler(new PauseHandler(this), KeyEvent.VK_F10);
    addKeyHandler(new QuitHandler(), KeyEvent.VK_Q, false, true, false);

    // toggle debug mode (bounding shapes, etc)
    addKeyHandler(new ToggleDebugHandler(this), KeyEvent.VK_TAB);

    // cycle toolbar rendering
    addKeyHandler(new CycleRenderHandler(this), KeyEvent.VK_EQUALS);

    addKeyHandler(new FocusConsoleHandler(this), KeyEvent.VK_ENTER);

    // manual scrolling
    addKeyHandler(new ScrollHandler(this, 5, 0), KeyEvent.VK_PAGE_UP);
    addKeyHandler(new ScrollHandler(this, -5, 0), KeyEvent.VK_PAGE_DOWN);

    // toggle scroll lock
    addKeyHandler(new LockViewportHandler(this, tryTheSpecial), java.awt.event.KeyEvent.VK_HOME);
    addKeyHandler(new LockViewportHandler(this), java.awt.event.KeyEvent.VK_END);

    addKeyHandler(new PrintHistory(this), java.awt.event.KeyEvent.VK_F1);

    // open imagetest in the editor
    addKeyHandler(new LaunchEditorHandler(this), java.awt.event.KeyEvent.VK_SCROLL_LOCK);

    // play a sound when space is pressed
    addKeyHandler(//  w  ww.  j a v a 2  s. co m
            new PlaySoundHandler(this, Tools.GetFile("org.slage.tests.content", "congratulations-escaped.ogg")),
            java.awt.event.KeyEvent.VK_SPACE);

    // save the game
    addKeyHandler(new SaveWithChooserDialog(this), java.awt.event.KeyEvent.VK_F5);

    // inventory dialog, we hope
    addKeyHandler(new ShowInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_F4);
    addKeyHandler(new CloseInventoryHandler(getPlayer()), java.awt.event.KeyEvent.VK_ESCAPE);

}

From source file:org.rdv.ui.MainPanel.java

private void initActions() {
    fileAction = new DataViewerAction("File", "File Menu", KeyEvent.VK_F);

    connectAction = new DataViewerAction("Connect", "Connect to RBNB server", KeyEvent.VK_C,
            KeyStroke.getKeyStroke(KeyEvent.VK_C, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = 5038790506859429244L;

        public void actionPerformed(ActionEvent ae) {
            if (rbnbConnectionDialog == null) {
                rbnbConnectionDialog = new RBNBConnectionDialog(frame, rbnb, dataPanelManager);
            } else {
                rbnbConnectionDialog.setVisible(true);
            }//from   ww  w. j av  a2 s.c  om
        }
    };

    disconnectAction = new DataViewerAction("Disconnect", "Disconnect from RBNB server", KeyEvent.VK_D,
            KeyStroke.getKeyStroke(KeyEvent.VK_D, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -1871076535376405181L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
            rbnb.disconnect();
        }
    };

    loginAction = new DataViewerAction("Login", "Login as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6105503896620555072L;

        public void actionPerformed(ActionEvent ae) {
            if (loginDialog == null) {
                loginDialog = new LoginDialog(frame);
            } else {
                loginDialog.setVisible(true);
            }
        }
    };

    logoutAction = new DataViewerAction("Logout", "Logout as a NEES user") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2517567766044673777L;

        public void actionPerformed(ActionEvent ae) {
            AuthenticationManager.getInstance().setAuthentication(null);
        }
    };

    loadAction = new DataViewerAction("Load Setup", "Load data viewer setup from file") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7197815395398039821L;

        public void actionPerformed(ActionEvent ae) {
            File configFile = UIUtilities.getFile(new RDVConfigurationFileFilter(), "Load");
            if (configFile != null) {
                try {
                    URL configURL = configFile.toURI().toURL();
                    ConfigurationManager.loadConfiguration(configURL);
                } catch (MalformedURLException e) {
                    DataViewer.alertError("\"" + configFile + "\" is not a valid configuration file URL.");
                }
            }
        }
    };

    saveAction = new DataViewerAction("Save Setup", "Save data viewer setup to file") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8259994975940624038L;

        public void actionPerformed(ActionEvent ae) {
            File file = UIUtilities.saveFile(new RDVConfigurationFileFilter());
            if (file != null) {
                if (file.getName().indexOf(".") == -1) {
                    file = new File(file.getAbsolutePath() + ".rdv");
                }

                // prompt for overwrite if file already exists
                if (file.exists()) {
                    int overwriteReturn = JOptionPane.showConfirmDialog(null,
                            file.getName() + " already exists. Do you want to overwrite it?", "Overwrite file?",
                            JOptionPane.YES_NO_OPTION);
                    if (overwriteReturn == JOptionPane.NO_OPTION) {
                        return;
                    }
                }

                ConfigurationManager.saveConfiguration(file);
            }
        }
    };

    importAction = new DataViewerAction("Import", "Import Menu", KeyEvent.VK_I, "icons/import.gif");

    exportAction = new DataViewerAction("Export", "Export Menu", KeyEvent.VK_E, "icons/export.gif");

    exportVideoAction = new DataViewerAction("Export video channels",
            "Export video on the server to the local computer") {
        /** serialization version identifier */
        private static final long serialVersionUID = -6420430928972633313L;

        public void actionPerformed(ActionEvent ae) {
            showExportVideoDialog();
        }
    };

    exitAction = new DataViewerAction("Exit", "Exit RDV", KeyEvent.VK_X) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3137490972014710133L;

        public void actionPerformed(ActionEvent ae) {
            Application.getInstance().exit(ae);
        }
    };

    controlAction = new DataViewerAction("Control", "Control Menu", KeyEvent.VK_C);

    realTimeAction = new DataViewerAction("Real Time", "View data in real time", KeyEvent.VK_R,
            KeyStroke.getKeyStroke(KeyEvent.VK_R, menuShortcutKeyMask), "icons/rt.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -7564783609370910512L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.monitor();
        }
    };

    playAction = new DataViewerAction("Play", "Playback data", KeyEvent.VK_P,
            KeyStroke.getKeyStroke(KeyEvent.VK_P, menuShortcutKeyMask), "icons/play.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 5974457444931142938L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.play();
        }
    };

    pauseAction = new DataViewerAction("Pause", "Pause data display", KeyEvent.VK_A,
            KeyStroke.getKeyStroke(KeyEvent.VK_S, menuShortcutKeyMask), "icons/pause.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5297742186923194460L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.pause();
        }
    };

    beginningAction = new DataViewerAction("Go to beginning", "Move the location to the start of the data",
            KeyEvent.VK_B, KeyStroke.getKeyStroke(KeyEvent.VK_B, menuShortcutKeyMask), "icons/begin.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 9171304956895497898L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationBegin();
        }
    };

    endAction = new DataViewerAction("Go to end", "Move the location to the end of the data", KeyEvent.VK_E,
            KeyStroke.getKeyStroke(KeyEvent.VK_E, menuShortcutKeyMask), "icons/end.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 1798579248452726211L;

        public void actionPerformed(ActionEvent ae) {
            controlPanel.setLocationEnd();
        }
    };

    gotoTimeAction = new DataViewerAction("Go to time", "Move the location to specific date time of the data",
            KeyEvent.VK_T, KeyStroke.getKeyStroke(KeyEvent.VK_T, menuShortcutKeyMask)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6411442297488926326L;

        public void actionPerformed(ActionEvent ae) {
            TimeRange timeRange = RBNBHelper.getChannelsTimeRange();
            double time = DateTimeDialog.showDialog(frame, rbnb.getLocation(), timeRange.start, timeRange.end);
            if (time >= 0) {
                rbnb.setLocation(time);
            }
        }
    };

    updateChannelListAction = new DataViewerAction("Update Channel List", "Update the channel list",
            KeyEvent.VK_U, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), "icons/refresh.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -170096772973697277L;

        public void actionPerformed(ActionEvent ae) {
            rbnb.updateMetadata();
        }
    };

    dropDataAction = new DataViewerAction("Drop Data", "Drop data if plaback can't keep up with data rate",
            KeyEvent.VK_D, "icons/drop_data.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 7079791364881120134L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            rbnb.dropData(menuItem.isSelected());
        }
    };

    viewAction = new DataViewerAction("View", "View Menu", KeyEvent.VK_V);

    showChannelListAction = new DataViewerAction("Show Channels", "", KeyEvent.VK_L, "icons/channels.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 4982129759386009112L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            channelListPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showMetadataPanelAction = new DataViewerAction("Show Properties", "", KeyEvent.VK_P,
            "icons/properties.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 430106771704397810L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            metadataPanel.setVisible(menuItem.isSelected());
            layoutSplitPane();
            leftPanel.resetToPreferredSizes();
        }
    };

    showControlPanelAction = new DataViewerAction("Show Control Panel", "", KeyEvent.VK_C,
            "icons/control.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 6401715717710735485L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            controlPanel.setVisible(menuItem.isSelected());
        }
    };

    showAudioPlayerPanelAction = new DataViewerAction("Show Audio Player", "", KeyEvent.VK_A,
            "icons/audio.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4248275698973916287L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            audioPlayerPanel.setVisible(menuItem.isSelected());
        }
    };

    showMarkerPanelAction = new DataViewerAction("Show Marker Panel", "", KeyEvent.VK_M, "icons/info.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -5253555511660929640L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            markerSubmitPanel.setVisible(menuItem.isSelected());
        }
    };

    dataPanelAction = new DataViewerAction("Arrange", "Arrange Data Panel Orientation", KeyEvent.VK_D);

    dataPanelHorizontalLayoutAction = new DataViewerAction("Horizontal Data Panel Orientation", "", -1,
            "icons/vertical.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = 3356151813557187908L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.VERTICAL_LAYOUT);
        }
    };

    dataPanelVerticalLayoutAction = new DataViewerAction("Vertical Data Panel Orientation", "", -1,
            "icons/horizontal.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -4629920180285927138L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelContainer.setLayout(DataPanelContainer.HORIZONTAL_LAYOUT);
        }
    };

    showHiddenChannelsAction = new DataViewerAction("Show Hidden Channels", "", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_H, menuShortcutKeyMask), "icons/hidden.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -2723464261568074033L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            channelListPanel.showHiddenChannels(selected);
        }
    };

    hideEmptyTimeAction = new DataViewerAction("Hide time with no data", "", KeyEvent.VK_D) {
        /** serialization version identifier */
        private static final long serialVersionUID = -3123608144249355642L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            boolean selected = menuItem.isSelected();
            controlPanel.hideEmptyTime(selected);
        }
    };

    fullScreenAction = new DataViewerAction("Full Screen", "", KeyEvent.VK_F,
            KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6882310862616235602L;

        public void actionPerformed(ActionEvent ae) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource();
            if (menuItem.isSelected()) {
                if (enterFullScreenMode()) {
                    menuItem.setSelected(true);
                } else {
                    menuItem.setSelected(false);
                }
            } else {
                leaveFullScreenMode();
                menuItem.setSelected(false);
            }
        }
    };

    windowAction = new DataViewerAction("Window", "Window Menu", KeyEvent.VK_W);

    closeAllDataPanelsAction = new DataViewerAction("Close all data panels", "", KeyEvent.VK_C,
            "icons/closeall.gif") {
        /** serialization version identifier */
        private static final long serialVersionUID = -8104876009869238037L;

        public void actionPerformed(ActionEvent ae) {
            dataPanelManager.closeAllDataPanels();
        }
    };

    helpAction = new DataViewerAction("Help", "Help Menu", KeyEvent.VK_H);

    usersGuideAction = new DataViewerAction("RDV Help", "Open the RDV User's Guide", KeyEvent.VK_H,
            KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)) {
        /** serialization version identifier */
        private static final long serialVersionUID = -2837190869008153291L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL usersGuideURL = new URL("http://it.nees.org/library/telepresence/rdv-19-users-guide.php");
                DataViewer.browse(usersGuideURL);
            } catch (Exception e) {
            }
        }
    };

    supportAction = new DataViewerAction("RDV Support", "Get support from NEESit", KeyEvent.VK_S) {
        /** serialization version identifier */
        private static final long serialVersionUID = -6855670513381679226L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL supportURL = new URL("http://it.nees.org/support/");
                DataViewer.browse(supportURL);
            } catch (Exception e) {
            }
        }
    };

    releaseNotesAction = new DataViewerAction("Release Notes", "Open the RDV Release Notes", KeyEvent.VK_R) {
        /** serialization version identifier */
        private static final long serialVersionUID = 7223639998298692494L;

        public void actionPerformed(ActionEvent ae) {
            try {
                URL releaseNotesURL = new URL("http://it.nees.org/library/rdv/rdv-release-notes.php");
                DataViewer.browse(releaseNotesURL);
            } catch (Exception e) {
            }
        }
    };

    aboutAction = new DataViewerAction("About RDV", "", KeyEvent.VK_A) {
        /** serialization version identifier */
        private static final long serialVersionUID = 3978467903181198979L;

        public void actionPerformed(ActionEvent ae) {
            showAboutDialog();
        }
    };

}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

/**
 * Creates new form MapFrame//from w w w.  ja  v a2  s . c  o m
 */
DSWorkbenchMainFrame() {
    initComponents();
    setAlwaysOnTop(false);
    if (!GlobalOptions.isMinimal()) {
        setTitle("DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION);
    } else {
        setTitle("DS Workbench Mini " + Constants.VERSION + Constants.VERSION_ADDITION);
    }

    jExportDialog.pack();
    jAddROIDialog.pack();

    JOutlookBar outlookBar = new JOutlookBar();
    outlookBar.addBar("Navigation", jNavigationPanel);
    outlookBar.addBar("Information", jInformationPanel);
    outlookBar.addBar("Karte", jMapPanel);
    outlookBar.addBar("ROI", jROIPanel);
    outlookBar.setVisibleBar(1);
    jSettingsScrollPane.setViewportView(outlookBar);

    mAbout = new AboutDialog(this, true);
    mAbout.pack();
    chooser.setDialogTitle("Speichern unter...");
    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".png"));
        }

        @Override
        public String getDescription() {
            return "PNG Image (*.png)";
        }
    });

    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f != null) && (f.isDirectory() || f.getName().endsWith(".jpeg"));
        }

        @Override
        public String getDescription() {
            return "JPEG Image (*.jpeg)";
        }
    });

    //Schedule Backup
    new Timer("BackupTimer", true).schedule(new BackupTask(), 60 * 10000, 60 * 10000);

    //give focus to map panel if mouse enters map
    jMapPanelHolder.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            jMapPanelHolder.requestFocusInWindow();
        }
    });

    getContentPane().setBackground(Constants.DS_BACK);
    pack();
    capabilityInfoPanel1.addActionListener(MapPanel.getSingleton());

    // <editor-fold defaultstate="collapsed" desc=" Add global KeyListener ">
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

        @Override
        public void eventDispatched(AWTEvent event) {
            if (event.getID() == KeyEvent.KEY_PRESSED) {
                KeyEvent e = (KeyEvent) event;
                if (DSWorkbenchMainFrame.getSingleton().isActive()) {
                    //move shortcuts
                    if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                        scroll(0.0, 2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                        scroll(0.0, -2.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                        scroll(-2.0, 0.0);
                    } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                        scroll(2.0, 0.0);
                    } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //shot minimap tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_AXE);
                    } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack axe tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_RAM);
                    } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack ram tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SNOB);
                    } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack snob tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SPY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack sword tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_LIGHT);
                    } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack light tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_HEAVY);
                    } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isShiftDown() && !e.isControlDown()
                            && !e.isAltDown()) {
                        //attack heavy tool shortcut
                        MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SWORD);
                    } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isControlDown() && !e.isAltDown()) {
                        //search frame shortcut
                        DSWorkbenchSearchFrame.getSingleton()
                                .setVisible(!DSWorkbenchSearchFrame.getSingleton().isVisible());
                    }
                }

                //misc shortcuts
                if ((e.getKeyCode() == KeyEvent.VK_0) && e.isAltDown()) {
                    //no tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_DEFAULT);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //measure tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MEASURE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //mark tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MARK);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //tag tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_TAG);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SUPPORT);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SELECTION);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_RADAR);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //attack ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    //res ingame tool shortcut
                    MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SEND_RES_INGAME);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //move minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MOVE);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //zoom minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ZOOM);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //shot minimap tool shortcut
                    MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SHOT);
                } else if ((e.getKeyCode() == KeyEvent.VK_T) && e.isControlDown() && !e.isShiftDown()
                        && !e.isAltDown()) {
                    //search time shortcut
                    ClockFrame.getSingleton().setVisible(!ClockFrame.getSingleton().isVisible());
                } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isAltDown() && !e.isShiftDown()
                        && !e.isControlDown()) {
                    planMapshot();
                } else if (e.getKeyCode() == KeyEvent.VK_F2) {
                    DSWorkbenchAttackFrame.getSingleton()
                            .setVisible(!DSWorkbenchAttackFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F3) {
                    DSWorkbenchMarkerFrame.getSingleton()
                            .setVisible(!DSWorkbenchMarkerFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F4) {
                    DSWorkbenchTroopsFrame.getSingleton()
                            .setVisible(!DSWorkbenchTroopsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F5) {
                    DSWorkbenchRankFrame.getSingleton()
                            .setVisible(!DSWorkbenchRankFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F6) {
                    DSWorkbenchFormFrame.getSingleton()
                            .setVisible(!DSWorkbenchFormFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F7) {
                    if (ServerSettings.getSingleton().isChurch()) {
                        DSWorkbenchChurchFrame.getSingleton()
                                .setVisible(!DSWorkbenchChurchFrame.getSingleton().isVisible());
                    }
                } else if (e.getKeyCode() == KeyEvent.VK_F8) {
                    DSWorkbenchConquersFrame.getSingleton()
                            .setVisible(!DSWorkbenchConquersFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F9) {
                    DSWorkbenchNotepad.getSingleton()
                            .setVisible(!DSWorkbenchNotepad.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F10) {
                    DSWorkbenchTagFrame.getSingleton()
                            .setVisible(!DSWorkbenchTagFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F11) {
                    DSWorkbenchStatsFrame.getSingleton()
                            .setVisible(!DSWorkbenchStatsFrame.getSingleton().isVisible());
                } else if (e.getKeyCode() == KeyEvent.VK_F12) {
                    DSWorkbenchSettingsDialog.getSingleton().setVisible(true);
                } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 1
                    centerROI(0);
                } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 2
                    centerROI(1);
                } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 3
                    centerROI(2);
                } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 4
                    centerROI(3);
                } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 5
                    centerROI(4);
                } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 6
                    centerROI(5);
                } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 7
                    centerROI(6);
                } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 8
                    centerROI(7);
                } else if ((e.getKeyCode() == KeyEvent.VK_9) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 9
                    centerROI(8);
                } else if ((e.getKeyCode() == KeyEvent.VK_0) && e.isControlDown() && e.isAltDown()
                        && !e.isShiftDown()) {
                    //ROI 10
                    centerROI(9);
                } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setSpaceDown(true);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    jMapPanelHolder.requestFocusInWindow();
                    MapPanel.getSingleton().setShiftDown(true);
                }
            } else if (event.getID() == KeyEvent.KEY_RELEASED) {
                KeyEvent e = (KeyEvent) event;
                if (e.getKeyCode() == KeyEvent.VK_SPACE) {
                    MapPanel.getSingleton().setSpaceDown(false);
                } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
                    MapPanel.getSingleton().setShiftDown(false);
                }
            }
        }
    }, AWTEvent.KEY_EVENT_MASK);
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Load UI Icons ">
    try {
        jOnlineLabel.setIcon(new ImageIcon("./graphics/icons/online.png"));
        jEnableClipboardWatchButton.setIcon(new ImageIcon("./graphics/icons/watch_clipboard.png"));
        jCenterIngameButton
                .setIcon(new ImageIcon(DSWorkbenchMainFrame.class.getResource("/res/ui/center_ingame.png")));
        jRefreshButton.setIcon(new ImageIcon("./graphics/icons/refresh.png"));
        jCenterCoordinateIngame.setIcon(new ImageIcon("./graphics/icons/center.png"));
    } catch (Exception e) {
        logger.error("Failed to load status icon(s)", e);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Check for desktop support ">
    if (!Desktop.isDesktopSupported()) {
        jCenterIngameButton.setEnabled(false);
        jCenterCoordinateIngame.setEnabled(false);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore last map position ">
    try {
        String x = GlobalOptions.getSelectedProfile().getProperty("last.x");
        String y = GlobalOptions.getSelectedProfile().getProperty("last.y");
        centerPosition(Double.parseDouble(x), Double.parseDouble(y));
    } catch (Exception e) {
        centerPosition(ServerSettings.getSingleton().getMapDimension().getCenterX(),
                ServerSettings.getSingleton().getMapDimension().getCenterY());
    }

    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc=" Restore other settings ">
    jShowMapPopup.setSelected(GlobalOptions.getProperties().getBoolean("show.map.popup"));
    jShowMouseOverInfo.setSelected(GlobalOptions.getProperties().getBoolean("show.mouseover.info"));
    jIncludeSupport.setSelected(GlobalOptions.getProperties().getBoolean("include.support"));
    jHighlightTribeVillages.setSelected(GlobalOptions.getProperties().getBoolean("highlight.tribes.villages"));
    jShowRuler.setSelected(GlobalOptions.getProperties().getBoolean("show.ruler"));
    jDisplayChurch.setSelected(GlobalOptions.getProperties().getBoolean("show.church"));
    jDisplayWatchtower.setSelected(GlobalOptions.getProperties().getBoolean("show.watchtower"));
    jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
    jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
    ServerSettings.getSingleton().addListener(new ServerSettingsListener() {
        @Override
        public void fireServerSettingsChanged() {
            jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch());
            jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower());
        }
    });
    int r = GlobalOptions.getProperties().getInt("radar.size");
    int hour = r / 60;
    jHourField.setText(Integer.toString(hour));
    jMinuteField.setText(Integer.toString(r - hour * 60));
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Skin Setup">
    DefaultComboBoxModel gpModel = new DefaultComboBoxModel(GlobalOptions.getAvailableSkins());
    jGraphicPacks.setModel(gpModel);
    String skin = GlobalOptions.getProperty("default.skin");
    if (gpModel.getIndexOf(skin) != -1) {
        jGraphicPacks.setSelectedItem(skin);
    } else {
        jGraphicPacks.setSelectedItem("default");
    }
    //</editor-fold>

    minZoom = GlobalOptions.getProperties().getDouble("map.zoom.min");
    maxZoom = GlobalOptions.getProperties().getDouble("map.zoom.max");
    dZoomInOutFactor = GlobalOptions.getProperties().getDouble("map.zoom.in.out.factor");

    mNotificationHideThread = new NotificationHideThread();
    mNotificationHideThread.start();
    SystrayHelper.installSystrayIcon();
    //update online state
    onlineStateChanged();
    restoreProperties();
}

From source file:com.xyphos.vmtgen.GUI.java

@Override
public boolean dispatchKeyEvent(KeyEvent ke) {
    if (KeyEvent.KEY_PRESSED == ke.getID()) {
        System.out.println(ke.toString());
        switch (ke.getKeyCode()) {
        case KeyEvent.VK_F1:
            generateVMT();//from  w w  w .  j av  a 2 s.com
            return true;

        case KeyEvent.VK_F2:
            setAllLocks(true);
            return true;

        case KeyEvent.VK_F3:
            setAllLocks(false);
            return true;

        case KeyEvent.VK_F4:
            toggleAllLocks();
            return true;

        case KeyEvent.VK_F5:
            showTextureFiles();
            return true;

        case KeyEvent.VK_F6:
            resetAllInput();
            return true;
        }
    }
    return false;
}

From source file:com.github.fritaly.dualcommander.DualCommander.java

public DualCommander() {
    // TODO Generate a fat jar at build time
    super(String.format("Dual Commander %s", Utils.getApplicationVersion()));

    if (logger.isInfoEnabled()) {
        logger.info(String.format("Dual Commander %s", Utils.getApplicationVersion()));
    }/*from   w  w  w .j a  va  2s . c  o m*/

    try {
        // Apply the JGoodies L&F
        UIManager.setLookAndFeel(new WindowsLookAndFeel());
    } catch (Exception e) {
        // Not supposed to happen
    }

    // Layout, columns & rows
    setLayout(new MigLayout("insets 0px", "[grow]0px[grow]", "[grow]0px[]"));

    // Create a menu bar
    final JMenu fileMenu = new JMenu("File");
    fileMenu.add(new JMenuItem(preferencesAction));
    fileMenu.add(new JSeparator());
    fileMenu.add(new JMenuItem(quitAction));

    final JMenu helpMenu = new JMenu("Help");
    helpMenu.add(new JMenuItem(aboutAction));

    final JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(helpMenu);

    setJMenuBar(menuBar);

    this.leftPane = new TabbedPane(preferences);
    this.leftPane.setName("Left");
    this.leftPane.addChangeListener(this);
    this.leftPane.addKeyListener(this);
    this.leftPane.addFocusListener(this);

    this.rightPane = new TabbedPane(preferences);
    this.rightPane.setName("Right");
    this.rightPane.addChangeListener(this);
    this.rightPane.addKeyListener(this);
    this.rightPane.addFocusListener(this);

    // Adding the 2 components to the same sizegroup ensures they always
    // keep the same width
    getContentPane().add(leftPane, "grow, sizegroup g1");
    getContentPane().add(rightPane, "grow, sizegroup g1, wrap");

    // The 7 buttons must all have the same width (they must belong to the
    // same size group)
    final JPanel buttonPanel = new JPanel(
            new MigLayout("insets 0px", StringUtils.repeat("[grow, sizegroup g1]", 7), "[grow]"));
    buttonPanel.add(viewButton, "grow");
    buttonPanel.add(editButton, "grow");
    buttonPanel.add(copyButton, "grow");
    buttonPanel.add(moveButton, "grow");
    buttonPanel.add(mkdirButton, "grow");
    buttonPanel.add(deleteButton, "grow");
    buttonPanel.add(quitButton, "grow");

    getContentPane().add(buttonPanel, "grow, span 2");

    // Register shortcuts at a global level (not on every component)
    final InputMap inputMap = this.leftPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, true), "view");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0, true), "edit");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0, true), "copy");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0, true), "move");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0, true), "mkdir");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0, true), "delete");
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_DOWN_MASK), "quit");

    final ActionMap actionMap = this.leftPane.getActionMap();
    actionMap.put("view", viewAction);
    actionMap.put("edit", editAction);
    actionMap.put("copy", copyAction);
    actionMap.put("move", moveAction);
    actionMap.put("mkdir", mkdirAction);
    actionMap.put("delete", deleteAction);
    actionMap.put("quit", quitAction);

    addWindowListener(this);
    addKeyListener(this);

    // Listen to preference change events
    this.preferences.addPropertyChangeListener(this);

    // Reload the last configuration and init the left & right panels
    // accordingly
    final Preferences prefs = Preferences.userNodeForPackage(this.getClass());

    // The user preferences must be loaded first because they're needed to
    // init the UI
    this.preferences.init(prefs.node("user.preferences"));
    this.leftPane.init(prefs.node("left.panel"));
    this.rightPane.init(prefs.node("right.panel"));

    if (logger.isInfoEnabled()) {
        logger.info("Loaded preferences");
    }

    // Init the buttons
    refreshButtons(this.leftPane.getActiveBrowser().getSelection());

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setExtendedState(JFrame.MAXIMIZED_BOTH);

    if (logger.isInfoEnabled()) {
        logger.info("UI initialized");
    }
}