Example usage for java.awt.event KeyEvent VK_ENTER

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

Introduction

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

Prototype

int VK_ENTER

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

Click Source Link

Document

Constant for the ENTER virtual key.

Usage

From source file:org.eobjects.datacleaner.panels.WelcomePanel.java

@Inject
protected WelcomePanel(AnalyzerBeansConfiguration configuration,
        AnalysisJobBuilderWindow analysisJobBuilderWindow, DCGlassPane glassPane,
        Provider<OptionsDialog> optionsDialogProvider, InjectorBuilder injectorBuilder,
        OpenAnalysisJobActionListener openAnalysisJobActionListener,
        DatabaseDriverCatalog databaseDriverCatalog, UserPreferences userPreferences) {
    super();//from  ww w .j a v  a  2  s . c  o  m
    _openAnalysisJobActionListener = openAnalysisJobActionListener;
    _configuration = configuration;
    _datastorePanels = new ArrayList<DatastorePanel>();
    _datastoreCatalog = (MutableDatastoreCatalog) configuration.getDatastoreCatalog();
    _analysisJobBuilderWindow = analysisJobBuilderWindow;
    _glassPane = glassPane;
    _optionsDialogProvider = optionsDialogProvider;
    _injectorBuilder = injectorBuilder;
    _databaseDriverCatalog = databaseDriverCatalog;
    _userPreferences = userPreferences;

    _browseJobsButton = new JButton("Browse jobs",
            imageManager.getImageIcon(IconUtils.MENU_OPEN, IconUtils.ICON_SIZE_SMALL));
    _browseJobsButton.setMargin(new Insets(1, 1, 1, 4));
    _browseJobsButton.addActionListener(openAnalysisJobActionListener);

    // initialize "analyze" button
    _analyzeButton = new JButton("Build job",
            imageManager.getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_SMALL));
    _analyzeButton.setMargin(new Insets(1, 1, 1, 1));
    _analyzeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (DatastorePanel datastorePanel : _datastorePanels) {
                if (datastorePanel.isSelected()) {
                    Datastore datastore = datastorePanel.getDatastore();

                    // open the connection here, to make any connection
                    // issues apparent early
                    try (DatastoreConnection datastoreConnection = datastore.openConnection()) {
                        datastoreConnection.getDataContext().getSchemaNames();
                        _analysisJobBuilderWindow.setDatastore(datastore);
                    }
                    return;
                }
            }
        }
    });

    // initialize search text field
    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter datastores");
    _searchDatastoreTextField
            .setBorder(new CompoundBorder(new EmptyBorder(4, 0, 0, 0), WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.setOpaque(false);
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    datastorePanel.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    String name = datastorePanel.getDatastore().getName().toLowerCase();
                    datastorePanel.setVisible(name.indexOf(text) != -1);
                }
                selectFirstVisibleDatastore();
            }
        }
    });
    _searchDatastoreTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                clickAnalyzeButton();
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                selectNextVisibleDatastore();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                selectPreviousVisibleDatastore();
            }
        }
    });

    setLayout(new VerticalLayout(4));

    add(Box.createVerticalStrut(10));

    final DCLabel jobsHeaderLabel = DCLabel.dark("Jobs");
    jobsHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(jobsHeaderLabel);

    _jobsListPanel = new DCPanel();
    final GridLayout jobsListLayout = new GridLayout(1, MAX_JOB_PANELS);
    jobsListLayout.setHgap(10);
    _jobsListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    _jobsListPanel.setLayout(jobsListLayout);

    final List<FileObject> recentJobFiles = getRecentJobFiles();

    updateJobsListPanel(recentJobFiles);

    add(_jobsListPanel);

    _moreRecentJobsButton = new JButton("More",
            imageManager.getImageIcon(IconUtils.FILE_FOLDER, IconUtils.ICON_SIZE_SMALL));
    _moreRecentJobsButton.setMargin(new Insets(1, 1, 1, 4));
    if (recentJobFiles.size() <= MAX_JOB_PANELS) {
        _moreRecentJobsButton.setEnabled(false);
    } else {
        _moreRecentJobsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final JPopupMenu popup = new JPopupMenu();
                for (int i = 3; i < recentJobFiles.size(); i++) {
                    final FileObject jobFile = recentJobFiles.get(i);
                    final JMenuItem menuItem = new OpenAnalysisJobMenuItem(jobFile,
                            _openAnalysisJobActionListener);
                    popup.add(menuItem);
                }
                popup.show(_moreRecentJobsButton, 0, _moreRecentJobsButton.getHeight());
            }
        });
    }

    final DCPanel jobsButtonPanel = new DCPanel();
    jobsButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
    jobsButtonPanel.add(_moreRecentJobsButton);
    jobsButtonPanel.add(_browseJobsButton);
    add(jobsButtonPanel);

    add(Box.createVerticalStrut(40));

    final DCLabel datastoreHeaderLabel = DCLabel.dark("Datastores");
    datastoreHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(datastoreHeaderLabel);

    final DCLabel registerNewDatastoreLabel = DCLabel.dark("Register new:");
    registerNewDatastoreLabel.setFont(WidgetUtils.FONT_HEADER2);

    final DCPanel newDatastorePanel = new DCPanel();
    newDatastorePanel.setLayout(new VerticalLayout(4));
    newDatastorePanel.setBorder(new EmptyBorder(10, 10, 10, 0));
    newDatastorePanel.add(registerNewDatastoreLabel);
    newDatastorePanel.add(createNewDatastorePanel());

    add(newDatastorePanel);

    _datastoreListPanel = new DCPanel();
    _datastoreListPanel.setLayout(new VerticalLayout(4));
    _datastoreListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    add(_datastoreListPanel);
    updateDatastores();

    final DCPanel datastoresButtonPanel = new DCPanel();
    datastoresButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    datastoresButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 0));
    datastoresButtonPanel.add(_analyzeButton);
    add(datastoresButtonPanel);
}

From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java

/**
 * This method initializes jPasswordField   
 *    /*w  w  w  .  ja v  a  2  s  .c  o  m*/
 * @return javax.swing.JPasswordField   
 */
private JPasswordField getJPasswordField() {
    if (jPasswordField == null) {
        jPasswordField = new JPasswordField();
        jPasswordField.setPreferredSize(new Dimension(200, 22));
        jPasswordField.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent e) {
                mEventHandler.handle(EventHandler.PTF_USER_PASSWORD);
            }
        });
        jPasswordField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                    mEventHandler.handle(EventHandler.ENTER_KEY_TYTPED);
                }
            }
        });
        jPasswordField.addFocusListener(new FocusListener() {
            @Override
            public void focusGained(FocusEvent e) {
                jPasswordField.selectAll();
            }

            @Override
            public void focusLost(FocusEvent e) {
                jPasswordField.select(0, 0);
            }
        });
    }
    return jPasswordField;
}

From source file:Console.java

public void keyPressed(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_BACK_SPACE || code == KeyEvent.VK_LEFT) {
        if (outputMark == getCaretPosition()) {
            e.consume();//ww  w  . j  ava  2 s.  com
        }
    } else if (code == KeyEvent.VK_HOME) {
        int caretPos = getCaretPosition();
        if (caretPos == outputMark) {
            e.consume();
        } else if (caretPos > outputMark) {
            if (!e.isControlDown()) {
                if (e.isShiftDown()) {
                    moveCaretPosition(outputMark);
                } else {
                    setCaretPosition(outputMark);
                }
                e.consume();
            }
        }
    } else if (code == KeyEvent.VK_ENTER) {
        returnPressed();
        e.consume();
    } else if (code == KeyEvent.VK_UP) {
        historyIndex--;
        if (historyIndex >= 0) {
            if (historyIndex >= history.size()) {
                historyIndex = history.size() - 1;
            }
            if (historyIndex >= 0) {
                String str = history.elementAt(historyIndex);
                int len = getDocument().getLength();
                replaceRange(str, outputMark, len);
                int caretPos = outputMark + str.length();
                select(caretPos, caretPos);
            } else {
                historyIndex++;
            }
        } else {
            historyIndex++;
        }
        e.consume();
    } else if (code == KeyEvent.VK_DOWN) {
        int caretPos = outputMark;
        if (history.size() > 0) {
            historyIndex++;
            if (historyIndex < 0) {
                historyIndex = 0;
            }
            int len = getDocument().getLength();
            if (historyIndex < history.size()) {
                String str = history.elementAt(historyIndex);
                replaceRange(str, outputMark, len);
                caretPos = outputMark + str.length();
            } else {
                historyIndex = history.size();
                replaceRange("", outputMark, len);
            }
        }
        select(caretPos, caretPos);
        e.consume();
    }
}

From source file:com.fanniemae.ezpie.actions.HighlightScan.java

private void confirmResults() {
    // wait until application is done scanning, by seeing when unique color is viewable
    int xx = (int) Math.round(Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2);
    int yy = 0;//from  ww  w .  j a  va2s.  co m

    boolean onScanFilesPage = false;
    while (!onScanFilesPage) {
        yy += 1;
        Color color = this._robot.getPixelColor(xx, yy);
        if (checkIfColorInRange(color, uniqueColorScanResultsPage, 10)) {
            onScanFilesPage = true;
            for (int i = 0; i < 3; i++) {
                moveMouseAndClick(xx, yy);
            }
        }
        if (yy > 300)
            yy = 0;
    }

    // select 'Confirm Results'
    keyPressReleaseShiftTab(200);
    keyPressRelease(KeyEvent.VK_ENTER, 200);
    sleep(5000);

}

From source file:client.InterfaceSalon.java

private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER && btnSalon.isEnabled()) {
        c.creerSalon(jTextField1.getText(), jTextField2.getText());
    }//from www.j a v  a2s .  com
}

From source file:com.rapidminer.gui.new_plotter.gui.dialog.AddParallelLineDialog.java

/**
 * Setup the GUI.//from  w w  w.  ja va  2s  .  co  m
 */
private void setupGUI() {
    JPanel mainPanel = new JPanel();
    this.setContentPane(mainPanel);

    // start layout
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    horizontalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.label"));
    horizontalLineRadiobutton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.tip"));
    horizontalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setHorizontalLineSelected();
        }
    });
    horizontalLineRadiobutton.setSelected(true);
    this.add(horizontalLineRadiobutton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    verticalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.label"));
    verticalLineRadiobutton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.tip"));
    verticalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalLineSelected();
        }
    });
    this.add(verticalLineRadiobutton, gbc);

    ButtonGroup group = new ButtonGroup();
    group.add(horizontalLineRadiobutton);
    group.add(verticalLineRadiobutton);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.CENTER;
    rangeAxisSelectionCombobox = new JComboBox();
    rangeAxisSelectionCombobox.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.range_axis_combobox.tip"));
    rangeAxisSelectionCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateYFieldValue();
        }
    });
    this.add(rangeAxisSelectionCombobox, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JLabel xLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.label"));
    this.add(xLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.insets = new Insets(2, 5, 2, 5);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    xField = new JTextField();
    xField.setText(String.valueOf(x));
    xField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyYInput(input);
        }
    });
    xField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.tip"));
    xField.setEnabled(false);
    this.add(xField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.NONE;
    JLabel yLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.label"));
    this.add(yLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    yField = new JTextField();
    yField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.tip"));
    yField.setText(String.valueOf(y));
    yField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyXInput(input);
        }
    });
    this.add(yField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(10, 5, 0, 5);
    modifyLineButton = new JButton();
    modifyLineButton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.tip"));
    modifyLineButton.setIcon(SwingTools.createIcon(
            "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.icon")));
    modifyLineButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            modifyLine();
        }
    });
    this.add(modifyLineButton, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(15, 5, 5, 5);
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 5, 5);
    okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.label"));
    okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.tip"));
    okButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.icon")));
    okButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.mne").toCharArray()[0]);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean successful = addSpecifiedLine();
            // don't dispose dialog if not successful
            if (!successful) {
                return;
            }

            AddParallelLineDialog.this.dispose();
        }
    });
    okButton.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                okButton.doClick();
            }
        }
    });
    this.add(okButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    cancelButton = new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.label"));
    cancelButton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.tip"));
    cancelButton.setIcon(SwingTools.createIcon(
            "24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.icon")));
    cancelButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.mne").toCharArray()[0]);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // cancel requested, close dialog
            AddParallelLineDialog.this.dispose();
        }
    });
    this.add(cancelButton, gbc);

    // misc settings
    this.setMinimumSize(new Dimension(300, 250));
    // center dialog
    this.setLocationRelativeTo(null);
    this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.title.label"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setModal(true);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowActivated(WindowEvent e) {
            okButton.requestFocusInWindow();
        }
    });
}

From source file:com.fanniemae.ezpie.actions.HighlightScan.java

private void saveResults() {
    // select 'Save Results'
    keyPressReleaseShiftTab(200);//  w ww .  j a  v a  2  s .  co  m
    keyPressRelease(KeyEvent.VK_ENTER, 200);
    sleep(2000);

    // navigate to Folder input text
    keyPressRelease(KeyEvent.VK_TAB, 500);
    sleep(500);

    keyPressRelease(KeyEvent.VK_BACK_SPACE, 200);

    for (int i = 0; i < 100; i++) {
        keyPressRelease(KeyEvent.VK_DELETE, 100);
    }
    sleep(100);

    // type folder to put results
    Keyboard keyboard = new Keyboard(this._robot);
    keyboard.type(_destination + "\\Results");
    System.out.println("Saving Results to: " + _destination + "Results");

    // press 'OK'
    for (int i = 0; i < 2; i++) {
        keyPressRelease(KeyEvent.VK_TAB, 200);
        sleep(200);
    }
    keyPressRelease(KeyEvent.VK_ENTER, 200);
    sleep(5000);

}

From source file:org.pmedv.blackboard.board.BoardDesignerPerspective.java

@Override
protected void initializeComponents() {
    setLayout(new BorderLayout());
    toolTabPane = new JTabbedPane(JTabbedPane.BOTTOM);
    horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

    ctx = AppContext.getContext();//  ww  w.ja va  2s  . co m
    resources = ctx.getBean(ResourceService.class);
    advisor = ctx.getBean(ApplicationWindowAdvisor.class);

    final String position = (String) Preferences.values
            .get("org.pmedv.blackboard.BoardDesignerPerspective.layerPanelPlacement");

    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {

            viewMap = new ViewMap();

            rootWindow = DockingUtil.createRootWindow(viewMap, true);
            rootWindow.getWindowBar(Direction.DOWN).setEnabled(true);
            rootWindow.getWindowProperties().setMinimizeEnabled(true);

            DockingWindowsTheme theme = new SoftBlueIceDockingTheme();

            rootWindow.getRootWindowProperties().addSuperObject(theme.getRootWindowProperties());
            rootWindow.getWindowProperties().getTabProperties().getHighlightedButtonProperties()
                    .getCloseButtonProperties().setVisible(false);
            rootWindow.getWindowProperties().getTabProperties().getNormalButtonProperties()
                    .getCloseButtonProperties().setVisible(false);

            editorArea = new TabWindow();
            editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties()
                    .getCloseButtonProperties().setVisible(false);
            editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties()
                    .getCloseButtonProperties().setVisible(false);
            editorArea.getWindowProperties().getTabProperties().getNormalButtonProperties()
                    .getMinimizeButtonProperties().setVisible(true);
            editorArea.getWindowProperties().getTabProperties().getHighlightedButtonProperties()
                    .getMinimizeButtonProperties().setVisible(true);

            DockingWindowAdapter dockingAdapter = new DockingWindowAdapter() {
                @Override
                public void windowClosing(DockingWindow window) throws OperationAbortedException {

                }
            };

            editorArea.addListener(dockingAdapter);
            setDockingListener(dockingAdapter);

            rootWindow.setWindow(editorArea);

            if (position.equalsIgnoreCase("left")) {
                horizontalSplitPane.setRightComponent(rootWindow);
            } else {
                horizontalSplitPane.setLeftComponent(rootWindow);
            }

            advisor.setCurrentEditorArea(editorArea);

        }

    });

    JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer();
    taskpanecontainer.setBackground(new Color(182, 191, 205));

    JXTaskPane shapePane = new JXTaskPane();
    shapePane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.shapes.title"));
    shapePane.add(ctx.getBean(ShapePropertiesPanel.class));
    taskpanecontainer.add(shapePane);

    ctx.getBean(ShapePropertiesPanel.class).getStartLineCombo().setSelectedItem(LineEdgeType.STRAIGHT);
    ctx.getBean(ShapePropertiesPanel.class).getEndLineCombo().setSelectedItem(LineEdgeType.STRAIGHT);
    ctx.getBean(ShapePropertiesPanel.class).getThicknessCombo().setSelectedItem(new BasicStroke(2.0f));

    JXTaskPane layerPane = new JXTaskPane();
    layerPane.setTitle(resources.getResourceByKey("BoardDesignerPerspective.layers"));
    layerPane.add(ctx.getBean(ShowLayersCommand.class).getLayerPanel());
    taskpanecontainer.add(layerPane);

    JScrollPane scrollPane = new JScrollPane(taskpanecontainer);

    if (position.equalsIgnoreCase("left")) {
        horizontalSplitPane.setLeftComponent(toolTabPane);
    } else {
        horizontalSplitPane.setRightComponent(toolTabPane);
    }

    horizontalSplitPane.setOneTouchExpandable(true);
    horizontalSplitPane.setDividerSize(10);

    toolTabPane.addTab(resources.getResourceByKey("tooltab.forms"), resources.getIcon("icon.paint"),
            scrollPane);

    final SymbolListPanel symbolListPanel = ctx.getBean(SymbolListPanel.class);
    toolTabPane.addTab(resources.getResourceByKey("tooltab.symbols"), resources.getIcon("icon.symbols"),
            symbolListPanel);

    final ModelListPanel modelListPanel = ctx.getBean(ModelListPanel.class);
    toolTabPane.addTab(resources.getResourceByKey("tooltab.models"), resources.getIcon("icon.model"),
            modelListPanel);

    add(horizontalSplitPane, BorderLayout.CENTER);

    commandArea = new RSyntaxTextArea();
    commandArea.setRows(1);
    commandArea.setColumns(100);

    JPanel commandPanel = new JPanel(new BorderLayout());
    commandPanel.add(new JLabel("Command :"), BorderLayout.WEST);
    commandPanel.add(commandArea, BorderLayout.CENTER);
    commandArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2),
            BorderFactory.createLineBorder(Color.BLACK)));
    add(commandPanel, BorderLayout.NORTH);
    setupAutoComplete();

    commandArea.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {

            if (e.getKeyCode() == KeyEvent.VK_ENTER) {

                if (commandArea.getText().startsWith("add ") && commandArea.getText().length() > 4
                        && commandArea.hasFocus()) {

                    PartFactory pf = AppContext.getContext().getBean(PartFactory.class);

                    String tokens[] = commandArea.getText().split(" ");
                    StringBuffer partName = new StringBuffer();

                    for (int i = 1; i < tokens.length; i++) {
                        partName.append(tokens[i] + " ");
                    }

                    String name = partName.toString().trim();

                    if (pf.getPartnames().contains(name)) {
                        e.consume();
                        commandArea.setText("");
                        BoardUtil.addPart(name, EditorUtils.getCurrentActiveEditor());
                    }

                } else if (commandArea.getText().equals("new")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(CreateBoardCommand.class).execute(null);
                } else if (commandArea.getText().equals("resistor")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(AddResistorCommand.class).execute(null);
                } else if (commandArea.getText().equals("diode")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(AddDiodeCommand.class).execute(null);
                } else if (commandArea.getText().equals("text")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(AddTextCommand.class).execute(null);
                } else if (commandArea.getText().equals("open")) {
                    e.consume();
                    commandArea.setText("");
                    new OpenBoardCommand().execute(null);
                } else if (commandArea.getText().equals("save")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(SaveBoardCommand.class).execute(null);
                } else if (commandArea.getText().equals("color")) {
                    e.consume();
                    commandArea.setText("");
                    AppContext.getContext().getBean(ChooseColorCommand.class).execute(null);
                }

            }

        }

    });

    horizontalSplitPane.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equalsIgnoreCase("dividerLocation")) {
                configProvider.getConfig().setDividerLocation(horizontalSplitPane.getDividerLocation());
            }
        }
    });

    ctx.getBean(ShapePropertiesPanel.class).getObjectField()
            .setText(resources.getResourceByKey("ShapePropertiesPanel.items.none"));
    ctx.getBean(ShapePropertiesPanel.class).getRotationSpinner().setEnabled(false);
    ctx.getBean(ShapePropertiesPanel.class).getStartAngleSpinner().setEnabled(false);

    initListeners();

}

From source file:client.InterfaceSalon.java

private void jTextField2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField2KeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER && btnSalon.isEnabled()) {
        c.creerSalon(jTextField1.getText(), jTextField2.getText());
    }//from   w w  w  .ja  v  a2 s  .  com
}

From source file:org.squidy.designer.zoom.impl.SourceCodeShape.java

private JEditorPane createCodePane(URL sourceCodeURL) {

    codePane = new JEditorPane() {
        @Override//from  w w w.j  a  v  a  2  s  . co  m
        protected void processComponentKeyEvent(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SPACE && e.isControlDown()) {
                System.out.println("Code completion");

                int caretPosition = codePane.getCaretPosition();

                String code = codePane.getText();
                switch (code.charAt(caretPosition - 1)) {
                case '.':
                    int pseudoCaret = caretPosition - 1;
                    StringBuilder word = new StringBuilder();
                    for (char c = code.charAt(--pseudoCaret); !isEndOfWord(c); c = code.charAt(--pseudoCaret)) {
                        word.append(c);
                    }

                    word = word.reverse();

                    System.out.println("WORD: " + word);

                    // Class<?> type =
                    // ReflectionUtil.loadClass(word.toString());
                    //                  
                    // System.out.println("TYPE: " + type);

                    JPopupMenu menu = new JPopupMenu("sdaf");
                    Point p = codePane.getCaret().getMagicCaretPosition();
                    System.out.println("CARET POS: " + p);
                    // Point p = codePane.get

                    // menu.setPreferredSize(new Dimension(200, 200));
                    menu.setLocation(30, 30);
                    menu.add("test");

                    codePane.add(menu);

                    // System.out.println(p);

                    // codePane.get

                    menu.show(codePane, p.x, p.y);

                    break;
                }
            }

            super.processComponentKeyEvent(e);
        }

        /**
         * @param c
         * @return
         */
        private boolean isEndOfWord(char c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t';
        }
    };

    EditorKit editorKit = new StyledEditorKit() {

        /**
         * 
         */
        private static final long serialVersionUID = 7024886168909204806L;

        public Document createDefaultDocument() {
            return new SyntaxDocument();
        }
    };

    codePane.setEditorKitForContentType("text/java", editorKit);
    codePane.setContentType("text/java");

    try {
        FileInputStream fis = new FileInputStream(sourceCodeURL.getPath());
        codePane.read(fis, null);
        originSourceCode = codePane.getText();

        computeHeightOfCodePane();
        codePane.setAutoscrolls(true);
    } catch (Exception e) {
        codePane.setText("File not found!");
    }

    codePane.requestFocus();
    codePane.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    codePane.addKeyListener(new KeyAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see
         * java.awt.event.KeyAdapter#keyPressed(java.awt.event.KeyEvent)
         */
        @Override
        public void keyPressed(KeyEvent e) {
            super.keyPressed(e);

            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER:
            case KeyEvent.VK_DELETE:
            case KeyEvent.VK_BACK_SPACE:
            case KeyEvent.VK_SPACE:
                computeHeightOfCodePane();
                break;
            }

            markDirty();
        }
    });

    // final JPopupMenu menu = new JPopupMenu();
    //
    // JMenuItem i = new JMenuItem("Option 1");
    // JMenuItem i2 = new JMenuItem("Option 2");
    // menu.add(i);
    // menu.add(i2);
    // edit.add(menu);
    // getComponent().addKeyListener(new KeyAdapter() {
    //      
    // public void keyTyped(KeyEvent e) {
    // if(e.getModifiers() == 2 && e.getKeyChar() == ' ') {
    // Point popupLoc = edit.getCaret().getMagicCaretPosition();
    // System.out.println(popupLoc);
    // menu.setLocation(new
    // Point((int)popupLoc.getX(),(int)popupLoc.getY()));
    // menu.setVisible(true);
    // }
    //      
    // }
    // });

    return codePane;
}