Example usage for java.awt KeyEventDispatcher KeyEventDispatcher

List of usage examples for java.awt KeyEventDispatcher KeyEventDispatcher

Introduction

In this page you can find the example usage for java.awt KeyEventDispatcher KeyEventDispatcher.

Prototype

KeyEventDispatcher

Source Link

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_TYPED) {
                e.setKeyChar('a');
            }/*from w w  w  .j  a v  a 2 s .  c  o  m*/
            boolean discardEvent = false;
            return discardEvent;
        }
    });
}

From source file:PVGraph.java

public PVGraph(Calendar date, int initialViewIndex) {
    super(WINDOW_TITLE_PREFIX);
    this.date = date;
    synchronized (graphs) {
        graphs.add(this);
    }/*from  w  w  w.  ja  va 2 s. com*/

    views = new PVGraphView[4];
    views[DAY_VIEW_INDEX] = new DayView();
    views[MONTH_VIEW_INDEX] = new MonthView();
    views[YEAR_VIEW_INDEX] = new YearView();
    views[YEARS_VIEW_INDEX] = new YearsView();

    tabPane = new JTabbedPane();
    for (PVGraphView v : views)
        tabPane.addTab(v.getTabLabel(), v.makePanel());
    tabPane.setSelectedIndex(initialViewIndex);
    setContentPane(tabPane);
    pack();
    try {
        java.net.URL url = getClass().getResource("sun.png");
        if (url != null)
            setIconImage(ImageIO.read(url));
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }
    ;
    setVisible(true);

    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
        public boolean dispatchKeyEvent(KeyEvent ke) {
            Object src = ke.getSource();
            if (src instanceof JComponent && ((JComponent) src).getRootPane().getContentPane() == tabPane) {
                if (ke.getID() == KeyEvent.KEY_TYPED) {
                    switch (ke.getKeyChar()) {
                    case 'd':
                        tabPane.setSelectedIndex(DAY_VIEW_INDEX);
                        return true;
                    case 'm':
                        tabPane.setSelectedIndex(MONTH_VIEW_INDEX);
                        return true;
                    case 'N' - 0x40:
                        new PVGraph((Calendar) PVGraph.this.date.clone(), tabPane.getSelectedIndex());
                        return true;
                    case 'Q' - 0x40:
                        dispatchEvent(new WindowEvent(PVGraph.this, WindowEvent.WINDOW_CLOSING));
                        return true;
                    case 'R' - 0x40:
                        loadProperties();
                        updateView();
                        return true;
                    case 'S':
                        try {
                            runSmatool();
                            updateView();
                        } catch (IOException ioe) {
                            System.err.println(ioe.getMessage());
                        }
                        return true;
                    case 'y':
                        tabPane.setSelectedIndex(YEAR_VIEW_INDEX);
                        return true;
                    case 'Y':
                        tabPane.setSelectedIndex(YEARS_VIEW_INDEX);
                        return true;
                    default:
                        return views[tabPane.getSelectedIndex()].handleKey(ke.getKeyChar());
                    }
                }
            }
            return false;
        }
    });
}

From source file:com.frostwire.gui.player.MediaPlayer.java

protected MediaPlayer() {
    lastRandomFiles = new LinkedList<MediaSource>();
    playExecutor = ExecutorsHelper.newProcessingQueue("AudioPlayer-PlayExecutor");

    String playerPath;//from   w  w  w  . ja v  a 2s .c  om
    playerPath = getPlayerPath();

    MPlayer.initialise(new File(playerPath));
    mplayer = new MPlayer();
    mplayer.addPositionListener(new PositionListener() {
        public void positionChanged(float currentTimeInSecs) {
            notifyProgress(currentTimeInSecs);
        }
    });
    mplayer.addStateListener(new StateListener() {
        public void stateChanged(MediaPlaybackState newState) {
            if (newState == MediaPlaybackState.Closed) { // This is the case
                                                         // mplayer is
                                                         // done with the
                                                         // current file
                playNextMedia();
            }
        }
    });
    mplayer.addIcyInfoListener(new IcyInfoListener() {
        public void newIcyInfoData(String data) {
            notifyIcyInfo(data);
        }
    });

    repeatMode = RepeatMode.values()[PlayerSettings.LOOP_PLAYLIST.getValue()];
    shuffle = PlayerSettings.SHUFFLE_PLAYLIST.getValue();
    playNextMedia = true;
    volume = PlayerSettings.PLAYER_VOLUME.getValue();
    notifyVolumeChanged();

    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_SPACE) {
                Object s = e.getComponent();
                if (!(s instanceof JTextField)
                        && !(s instanceof JTable && ((JTable) s).isEditing() && !(s instanceof JCheckBox))) {
                    togglePause();
                    return true;
                }
            }
            return false;
        }
    });

    // prepare to receive UI events
    MPlayerUIEventHandler.instance().addListener(this);
}

From source file:org.nekorp.workflow.desktop.view.AppMainWindow.java

/**
 * call this somewhere in your GUI construction
 *//*  w w w  . j av  a 2s. c om*/
private void setupKeyShortcut() {
    KeyStroke key1 = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK);
    actionMap.put(key1, new AbstractAction("guardar") {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (editorMonitor.hasChange()) {
                try {
                    aplication.guardaServicio();
                } catch (IllegalArgumentException ex) {
                    //no lo guardo.
                }
            }
        }
    });
    //        key1 = KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_DOWN_MASK);
    //        actionMap.put(key1, new AbstractAction("deshacer") {
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //                if (editorMonitor.hasChange()) {
    //                    editorMonitor.undo();
    //                }
    //            }
    //        });
    //        key1 = KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_DOWN_MASK);
    //        actionMap.put(key1, new AbstractAction("rehacer") {
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //                editorMonitor.redo();
    //            }
    //        });
    // add more actions..

    KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    kfm.addKeyEventDispatcher(new KeyEventDispatcher() {
        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e);
            if (actionMap.containsKey(keyStroke)) {
                final Action a = actionMap.get(keyStroke);
                final ActionEvent ae = new ActionEvent(e.getSource(), e.getID(), null);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        a.actionPerformed(ae);
                    }
                });
                return true;
            }
            return false;
        }
    });
}

From source file:fs.MainWindow.java

public MainWindow() {
    initComponents();/*from w ww  . j  a  va2s .  co  m*/
    //inicializacao do modelo numerido usado na definicao dos parametros.
    jS_QuantizationValue.setModel(new SpinnerNumberModel(2, 1, Integer.MAX_VALUE, 1));
    jS_MaxResultListSE.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1));
    jS_MaxSetSizeSE.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1));
    jS_MaxSetSizeCV.setModel(new SpinnerNumberModel(3, 1, Integer.MAX_VALUE, 1));
    jS_NrExecutionsCV.setModel(new SpinnerNumberModel(10, 1, Integer.MAX_VALUE, 1));
    jS_ThresholdEntropy.setModel(new SpinnerNumberModel(0.3, 0, 1, 0.05));
    jS_QEntropyCV.setModel(new SpinnerNumberModel(1d, 0.1d, Double.MAX_VALUE, 0.1d));
    jS_AlphaCV.setModel(new SpinnerNumberModel(1d, 0d, Double.MAX_VALUE, 0.1d));
    jS_QEntropySE.setModel(new SpinnerNumberModel(1d, 0.1d, Double.MAX_VALUE, 0.1d));
    jS_AlphaSE.setModel(new SpinnerNumberModel(1d, 0d, Double.MAX_VALUE, 0.1d));

    //captura teclas pressionadas, se for F1 aciona o JFrame Help.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_F1 && e.getID() == KeyEvent.KEY_PRESSED) {
                if (help != null) {
                    help.setVisible(false);
                    help.dispose();
                }
                if (jTabbedPane1.getSelectedIndex() == 0) {
                    help = new HelpInput();
                } else if (jTabbedPane1.getSelectedIndex() == 1) {
                    help = new HelpQuantization();
                } else if (jTabbedPane1.getSelectedIndex() == 2) {
                    help = new HelpFS();
                } else if (jTabbedPane1.getSelectedIndex() == 3) {
                    help = new HelpCV();
                }
                help.setVisible(true);
                return true;
            }
            return false;
        }
    });
}

From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java

/**
 * @throws HeadlessException// w w w .  j  a  v a  2 s. c o  m
 */
public AgentDebuggerFrame(final boolean isStandalone, String serviceUrl) throws HeadlessException {
    super("Intuit Tank Agent Debugger");
    workingDir = PanelBuilder.createWorkingDir(this, serviceUrl);
    setSize(new Dimension(1024, 800));
    setBounds(new Rectangle(getSize()));
    setPreferredSize(getSize());
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLayout(new BorderLayout());
    this.standalone = isStandalone;
    addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            quit();
        }
    });
    errorIcon = ActionProducer.getIcon("bullet_error.png", IconSize.SMALL);
    modifiedIcon = ActionProducer.getIcon("bullet_code_change.png", IconSize.SMALL);
    skippedIcon = ActionProducer.getIcon("skip.png", IconSize.SMALL);

    this.glassPane = new InfiniteProgressPanel();
    setGlassPane(glassPane);
    debuggerActions = new ActionProducer(this, serviceUrl);
    requestResponsePanel = new RequestResponsePanel(this);
    requestResponsePanel.init();
    testPlanChooser = new JComboBox();
    testPlanChooser.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent event) {
            if (event.getItem() != null) {
                HDTestPlan selected = (HDTestPlan) event.getItem();
                if (!selected.equals(currentTestPlan)) {
                    setCurrentTestPlan(selected);
                }
            }

        }
    });

    tankClientChooser = new JComboBox<TankClientChoice>();
    debuggerActions.setChoiceComboBoxOptions(tankClientChooser);

    actionComponents = new ActionComponents(standalone, testPlanChooser, tankClientChooser, debuggerActions);
    addScriptChangedListener(actionComponents);
    setJMenuBar(actionComponents.getMenuBar());

    Component topPanel = PanelBuilder.createTopPanel(actionComponents);
    Component bottomPanel = PanelBuilder.createBottomPanel(this);
    Component contentPanel = PanelBuilder.createContentPanel(this);

    final JPopupMenu popup = actionComponents.getPopupMenu();
    scriptEditorTA.setPopupMenu(null);

    scriptEditorTA.addMouseListener(new MouseAdapter() {
        int lastHash;

        @Override
        public void mousePressed(MouseEvent e) {
            maybeShow(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            maybeShow(e);
        }

        private void maybeShow(MouseEvent e) {
            if (lastHash == getHash(e)) {
                return;
            }
            if (e.isPopupTrigger()) {
                // select the line
                try {
                    int offset = scriptEditorTA.viewToModel(e.getPoint());
                    Rectangle modelToView = scriptEditorTA.modelToView(offset);
                    Point point = new Point(modelToView.x + 1, e.getPoint().y);
                    if (modelToView.contains(point)) {
                        if (!multiSelect) {
                            int line = scriptEditorTA.getLineOfOffset(offset);
                            scriptEditorTA.setCurrentLine(line);
                        }
                        popup.show(e.getComponent(), e.getX(), e.getY());
                    }
                } catch (BadLocationException e1) {
                    e1.printStackTrace();
                }
            } else if (e.isShiftDown()) {
                int line = scriptEditorTA.getCaretLineNumber();
                int start = Math.min(line, lastLine);
                int end = Math.max(line, lastLine);
                multiSelect = end - start > 1;
                if (multiSelect) {
                    multiSelectStart = start;
                    multiSelectEnd = end;
                    try {
                        scriptEditorTA.setEnabled(true);
                        scriptEditorTA.select(scriptEditorTA.getLineStartOffset(start),
                                scriptEditorTA.getLineEndOffset(end));
                        scriptEditorTA.setEnabled(false);
                    } catch (BadLocationException e1) {
                        e1.printStackTrace();
                        multiSelect = false;
                    }
                }
            } else {
                multiSelect = false;
                lastLine = scriptEditorTA.getCaretLineNumber();
            }
            lastHash = getHash(e);
        }

        private int getHash(MouseEvent e) {
            return new HashCodeBuilder().append(e.getButton()).append(e.getSource().hashCode())
                    .append(e.getPoint()).toHashCode();
        }

    });

    JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mainSplit.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    mainSplit.setTopComponent(contentPanel);
    mainSplit.setBottomComponent(bottomPanel);
    mainSplit.setDividerLocation(600);
    mainSplit.setResizeWeight(0.8D);
    mainSplit.setDividerSize(5);

    add(topPanel, BorderLayout.NORTH);
    add(mainSplit, BorderLayout.CENTER);

    WindowUtil.centerOnScreen(this);
    pack();

    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();

    manager.addKeyEventDispatcher(new KeyEventDispatcher() {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_PRESSED) {
                handleKeyEvent(e);
            }
            return false;
        }
    });
}

From source file:com.mirth.connect.client.ui.Frame.java

public Frame() {
    // Load RSyntaxTextArea language support
    LanguageSupportFactory.get().addLanguageSupport(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT,
            MirthJavaScriptLanguageSupport.class.getName());

    rightContainer = new JXTitledPanel();
    channelTagInfo = new ChannelTagInfo();
    deployedChannelTagInfo = new ChannelTagInfo();

    taskPaneContainer = new JXTaskPaneContainer();

    StringBuilder titleText = new StringBuilder();

    if (!StringUtils.isBlank(PlatformUI.SERVER_NAME)) {
        titleText.append(PlatformUI.SERVER_NAME);
    } else {/*from ww  w. ja  v a 2 s .co  m*/
        titleText.append(PlatformUI.SERVER_URL);
    }

    titleText.append(" - " + UIConstants.TITLE_TEXT);

    setTitle(titleText.toString());
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    setIconImage(new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/mirth_32_ico.png"))
            .getImage());
    makePaneContainer();

    connectionError = false;

    this.addComponentListener(new ComponentListener() {

        public void componentResized(ComponentEvent e) {
            if (channelEditPanel != null && channelEditPanel.filterPane != null) {
                channelEditPanel.filterPane.resizePanes();
            }
            if (channelEditPanel != null && channelEditPanel.transformerPane != null) {
                channelEditPanel.transformerPane.resizePanes();
            }
        }

        public void componentHidden(ComponentEvent e) {
        }

        public void componentShown(ComponentEvent e) {
        }

        public void componentMoved(ComponentEvent e) {
        }
    });

    this.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            if (logout(true)) {
                System.exit(0);
            }
        }
    });

    keyEventDispatcher = new KeyEventDispatcher() {

        @Override
        public boolean dispatchKeyEvent(KeyEvent e) {
            // Update the state of the accelerator key (CTRL on Windows)
            updateAcceleratorKeyPressed(e);
            return false;
        }
    };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(keyEventDispatcher);
}

From source file:com.igormaznitsa.sciareto.ui.MainFrame.java

private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed
    final Component currentComponent = this.tabPane.getSelectedComponent();
    if (!(currentComponent instanceof Container)) {
        LOGGER.warn("Detected attempt to full screen not a container : " + currentComponent);
        return;/*from w  ww.j  a  v a  2s . c  o m*/
    }

    final GraphicsConfiguration gconfig = this.getGraphicsConfiguration();
    if (gconfig != null) {
        final GraphicsDevice device = gconfig.getDevice();
        if (device.isFullScreenSupported()) {
            if (device.getFullScreenWindow() == null) {
                final JLabel label = new JLabel("Opened in full screen");
                final int tabIndex = this.tabPane.getSelectedIndex();
                this.tabPane.setComponentAt(tabIndex, label);
                final JWindow window = new JWindow(Main.getApplicationFrame());
                window.setAlwaysOnTop(true);
                window.setContentPane((Container) currentComponent);

                endFullScreenIfActive();

                final KeyEventDispatcher fullScreenEscCatcher = new KeyEventDispatcher() {
                    @Override
                    public boolean dispatchKeyEvent(@Nonnull final KeyEvent e) {
                        if (e.getID() == KeyEvent.KEY_PRESSED && (e.getKeyCode() == KeyEvent.VK_ESCAPE
                                || e.getKeyCode() == KeyEvent.VK_F11)) {
                            endFullScreenIfActive();
                            return true;
                        }
                        return false;
                    }
                };

                if (this.taskToEndFullScreen.compareAndSet(null, new Runnable() {
                    @Override
                    public void run() {
                        try {
                            window.dispose();
                        } finally {
                            tabPane.setComponentAt(tabIndex, currentComponent);
                            device.setFullScreenWindow(null);
                            KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                    .removeKeyEventDispatcher(fullScreenEscCatcher);
                        }
                    }
                })) {
                    try {
                        KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                .addKeyEventDispatcher(fullScreenEscCatcher);
                        device.setFullScreenWindow(window);
                    } catch (Exception ex) {
                        LOGGER.error("Can't turn on full screen", ex);
                        endFullScreenIfActive();
                        KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                .removeKeyEventDispatcher(fullScreenEscCatcher);
                    }
                } else {
                    LOGGER.error("Unexpected state, processor is not null!");
                }
            } else {
                LOGGER.warn("Attempt to full screen device which already in full screen!");
            }
        } else {
            LOGGER.warn("Device doesn's support full screen");
            DialogProviderManager.getInstance().getDialogProvider()
                    .msgWarn("The Device doesn't support full-screen mode!");
        }
    } else {
        LOGGER.warn("Can't find graphics config for the frame");
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void initGUI() {
    try {//from   w ww. j ava  2  s .c  om
        language = Utf8ResourceBundle.getBundle("language_" + Setting.getInstance().getCurrentLanguage());

        // $hide>>$
        if (os == OSType.win) {
            if (!new File("PauseBochs.exe").exists() || !new File("StopBochs.exe").exists()) {
                JOptionPane.showMessageDialog(null, MyLanguage.getString("PauseBochsExe"),
                        MyLanguage.getString("Error"), JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            }
            if (!new File("ndisasm.exe").exists()) {
                JOptionPane.showMessageDialog(null, MyLanguage.getString("NdisasmExe"),
                        MyLanguage.getString("Error"), JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            }
        }
        // $hide<<$
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        {
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            if (Global.isBeta) {
                this.setTitle(MyLanguage.getString("Title") + " " + Global.version
                        + " , This is beta version, if you found a bug, please try older official release");
            } else {
                this.setTitle(MyLanguage.getString("Title") + " " + Global.version);
            }

            this.setIconImage(
                    new ImageIcon(getClass().getClassLoader().getResource("com/peterbochs/icons/peter.png"))
                            .getImage());
            this.addWindowListener(new WindowAdapter() {
                public void windowOpened(WindowEvent evt) {
                    thisWindowOpened(evt);
                }

                public void windowActivated(WindowEvent evt) {
                    thisWindowActivated(evt);
                }

                public void windowClosing(WindowEvent evt) {
                    thisWindowClosing(evt);
                }
            });
        }
        {
            jToolBar1 = new JToolBar();
            getContentPane().add(jToolBar1, BorderLayout.NORTH);
            {
                startBochsButton = new JButton();
                jToolBar1.add(startBochsButton);
                startBochsButton.setText(MyLanguage.getString("Start_bochs"));
                startBochsButton.setToolTipText("Launch bochs");
                startBochsButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/peterbochs/icons/famfam_icons/accept.png")));
                startBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        startBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                stopBochsButton = new JButton();
                jToolBar1.add(stopBochsButton);
                stopBochsButton.setText(MyLanguage.getString("Stop_bochs"));
                stopBochsButton.setToolTipText("Quit bochs");
                stopBochsButton.setIcon(new ImageIcon(
                        getClass().getClassLoader().getResource("com/peterbochs/icons/famfam_icons/stop.png")));
                stopBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        stopBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                runBochsButton = new JDropDownButton();
                jToolBar1.add(runBochsButton);
                runBochsButton.setText(MyLanguage.getString("Run_bochs"));
                runBochsButton.setToolTipText("Start emulation");
                runBochsButton.setMaximumSize(new java.awt.Dimension(85, 26));
                runBochsButton.add(getJRunBochsAndSkipBreakpointMenuItem());
                runBochsButton.add(getJRunCustomCommandMenuItem());
                runBochsButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/peterbochs/icons/famfam_icons/resultset_next.png")));
                runBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        runBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                stepBochsButton = new JDropDownButton();
                jToolBar1.add(stepBochsButton);
                jToolBar1.add(getJStepOverDropDownButton());
                jToolBar1.add(getJFastStepBochsButton());
                stepBochsButton.setIcon(new ImageIcon(
                        getClass().getClassLoader().getResource("com/peterbochs/icons/famfam_icons/step.png")));
                stepBochsButton.setText(MyLanguage.getString("Step"));
                stepBochsButton.setMaximumSize(new java.awt.Dimension(85, 26));
                stepBochsButton.add(getJStep10MenuItem());
                stepBochsButton.add(getJStep100MenuItem());
                stepBochsButton.add(getJStepNMenuItem());
                stepBochsButton.add(getJStepUntilCallOrJumpMenuItem());
                stepBochsButton.add(getJStepUntilRetMenuItem());
                stepBochsButton.add(getJStepUntilIRetMenuItem());
                stepBochsButton.add(getJStepUntilMovMenuItem());
                stepBochsButton.add(getJStepUntilIPBigChangeMenuItem());
                stepBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        stepBochsButtonActionPerformed(evt);
                    }
                });
            }
            {
                nextButton = new JButton();
                nextButton.setIcon(new ImageIcon(
                        getClass().getClassLoader().getResource("com/peterbochs/icons/famfam_icons/step.png")));
                nextButton.setText(MyLanguage.getString("Nexti"));
                nextButton.setToolTipText("c/c++ level step-in");
                jToolBar1.add(nextButton);
                jToolBar1.add(getNextOverButton());
                nextButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        nextButtonActionPerformed(evt);
                    }
                });
            }
            {
                jUpdateBochsButton = new JButton();
                jToolBar1.add(jUpdateBochsButton);
                jToolBar1.add(getJExportToExcelButton());
                jToolBar1.add(getJSettingButton());
                jToolBar1.add(getJRegisterToggleButton());
                jToolBar1.add(getJSourceLevelDebuggerButton());
                jToolBar1.add(getJProfilerToggleButton());
                jToolBar1.add(getJLogToggleButton());
                jToolBar1.add(getJOSLogToggleButton());
                jUpdateBochsButton.setEnabled(true);
                jUpdateBochsButton.setText(MyLanguage.getString("Update"));
                jUpdateBochsButton.setIcon(new ImageIcon(getClass().getClassLoader()
                        .getResource("com/peterbochs/icons/famfam_icons/arrow_refresh.png")));
                jUpdateBochsButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jUpdateBochsButtonActionPerformed(evt);
                    }
                });
            }
        }
        {
            jStatusPanel = new JPanel();
            BorderLayout jStatusPanelLayout = new BorderLayout();
            jStatusPanel.setLayout(jStatusPanelLayout);
            getContentPane().add(jStatusPanel, BorderLayout.SOUTH);
            getContentPane().add(getJMainPanel());
            {
                jStatusProgressBar = new JProgressBar();
                jStatusPanel.add(jStatusProgressBar, BorderLayout.WEST);
                jStatusPanel.add(getJPanel25(), BorderLayout.CENTER);
            }
        }
        {
            jMenuBar1 = new JMenuBar();
            setJMenuBar(jMenuBar1);
            {
                jMenu3 = new JMenu();
                jMenuBar1.add(jMenu3);
                jMenu3.setText(MyLanguage.getString("File"));
                {
                    jSeparator2 = new JSeparator();
                    jMenu3.add(jSeparator2);
                }
                {
                    exitMenuItem = new JMenuItem();
                    jMenu3.add(exitMenuItem);
                    exitMenuItem.setText(MyLanguage.getString("Exit"));
                    exitMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exitMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            {
                jMenu4 = new JMenu();
                jMenuBar1.add(jMenu4);
                jMenuBar1.add(getJFontMenu());
                jMenuBar1.add(getJMenu6());
                jMenuBar1.add(getJSystemMenu());
                jMenu4.setText(MyLanguage.getString("Bochs"));
                {
                    startBochsMenuItem = new JMenuItem();
                    jMenu4.add(startBochsMenuItem);
                    startBochsMenuItem.setText(MyLanguage.getString("Start_bochs"));
                    startBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            startBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    stopBochsMenuItem = new JMenuItem();
                    jMenu4.add(stopBochsMenuItem);
                    stopBochsMenuItem.setText(MyLanguage.getString("Stop_bochs"));
                    stopBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            stopBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    jSeparator1 = new JSeparator();
                    jMenu4.add(jSeparator1);
                }
                {
                    runBochsMenuItem = new JMenuItem();
                    jMenu4.add(runBochsMenuItem);
                    runBochsMenuItem.setText(MyLanguage.getString("Run_bochs"));
                    runBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            runBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    pauseBochsMenuItem = new JMenuItem();
                    jMenu4.add(pauseBochsMenuItem);
                    pauseBochsMenuItem.setText(MyLanguage.getString("Pause_bochs"));
                    pauseBochsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            pauseBochsMenuItemActionPerformed(evt);
                        }
                    });
                }
                {
                    jUpdateBochsStatusMenuItem = new JMenuItem();
                    jMenu4.add(jUpdateBochsStatusMenuItem);
                    jUpdateBochsStatusMenuItem.setText(MyLanguage.getString("Update_bochs_status"));
                    jUpdateBochsStatusMenuItem.setBounds(83, 86, 79, 20);
                    jUpdateBochsStatusMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            jUpdateBochsStatusMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
            {
                jMenu5 = new JMenu();
                jMenuBar1.add(jMenu5);
                jMenu5.setText(MyLanguage.getString("Help"));
                {
                    aboutUsMenuItem = new JMenuItem();
                    jMenu5.add(aboutUsMenuItem);
                    jMenu5.add(getJHelpRequestMenuItem());
                    jMenu5.add(getJJVMMenuItem());
                    jMenu5.add(getShortcutHelpMenuItem());
                    jMenu5.add(getJLicenseMenuItem());
                    aboutUsMenuItem.setText(MyLanguage.getString("About_us"));
                    aboutUsMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            aboutUsMenuItemActionPerformed(evt);
                        }
                    });
                }
            }
        }
        if (Setting.getInstance().getWidth() == 0 || Setting.getInstance().getHeight() == 0) {
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setSize(screenSize.width * 2 / 3, screenSize.height * 4 / 5);
        } else {
            setSize(Setting.getInstance().getWidth(), Setting.getInstance().getHeight());
        }
        int x = Setting.getInstance().getX();
        int y = Setting.getInstance().getY();
        if (x <= 0 || y <= 0) {
            this.setLocationRelativeTo(null);
        } else {
            setLocation(x, y);
        }

        jSplitPane1.setDividerLocation(Setting.getInstance().getDivX());
        jSplitPane2.setDividerLocation(Setting.getInstance().getDivY());

        jOSDebugInformationPanel1.getjMainSplitPane()
                .setDividerLocation(Setting.getInstance().getOsDebugSplitPane_DividerLocation());
        // pack();
        initGlobalFontSetting(new Font(Setting.getInstance().getFontFamily(), Font.PLAIN,
                Setting.getInstance().getFontsize()));
        jInstrumentPanel.setThing(jStatusProgressBar, jStatusLabel);

        // prevent null jmenuitem
        getJInstructionPanelPopupMenu();
        // end prevent null jmenuitem

        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
            public boolean dispatchKeyEvent(KeyEvent e) {
                if (e.getID() == KeyEvent.KEY_RELEASED) {
                    int keycode = e.getKeyCode();
                    if (keycode == 112) {
                        jTabbedPane3.setSelectedIndex(0);
                    } else if (keycode == 113) {
                        jTabbedPane3.setSelectedIndex(1);
                    } else if (keycode == 114) {
                        jTabbedPane3.setSelectedIndex(2);
                    } else if (keycode == 115) {
                        jTabbedPane3.setSelectedIndex(3);
                    } else if (keycode == 116) {
                        if (startBochsButton.isEnabled()) {
                            startBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 117) {
                        if (stopBochsButton.isEnabled()) {
                            stopBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 118) {
                        if (runBochsButton.isEnabled()) {
                            runBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 119) {
                        if (stepBochsButton.isEnabled()) {
                            stepBochsButtonActionPerformed(null);
                        }
                    } else if (keycode == 120) {
                        if (fastStepBochsButton.isEnabled()) {
                            fastStepButtonActionPerformed(null);
                        }
                    }
                }

                // If the key should not be dispatched to the
                // focused component, set discardEvent to true
                boolean discardEvent = false;
                return discardEvent;
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(ERROR);
    }
}