List of usage examples for java.awt.event KeyEvent VK_ENTER
int VK_ENTER
To view the source code for java.awt.event KeyEvent VK_ENTER.
Click Source Link
From source file:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java
public SearchableTablePanel(String pageName, String[] columnNames, Class[] columnClasses, int[] hiddenColumns, boolean allowSearch, boolean allowSort, int defaultRows, boolean allowPages, TableSelectionType selectionType, int defaultRowsRetrieved, DataRetriever<Object[]> retriever) { this.pageName = pageName; this.rowsPerPageX = defaultRows; this.defaultRowsRetrieved = defaultRowsRetrieved; this.retriever = retriever; this.hiddenColumns = hiddenColumns; table = new SortableTable() { @Override/*from w w w. j av a2s. c o m*/ public Component prepareRenderer(TableCellRenderer renderer, int row, int col) { synchronized (SearchableTablePanel.this) { JComponent comp = (JComponent) super.prepareRenderer(renderer, row, col); // Even index, selected or not selected if (isRowToggled(TableModelWrapperUtils.getActualRowAt(this.getSortableTableModel(), row))) { //this.getActualRowAt(this.getSortedRowAt(row)))) { comp.setBackground(new Color(178, 225, 92)); } else if (isCellSelected(row, col)) { //comp.setBackground(new Color(75, 149, 229)); comp.setBackground(SELECTED_COLOUR); } else if (selectedRows != null && selectedRows.contains(TableModelWrapperUtils.getActualRowAt(getModel(), row))) { //comp.setBackground(SELECTED_COLOUR); } else if (row % 2 == 0 && !isCellSelected(row, col)) { comp.setBackground(Color.WHITE); } else { comp.setBackground(DARK_COLOUR); } comp.setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 7)); return comp; } } @Override public String getToolTipText(MouseEvent e) { return getToolTip( TableModelWrapperUtils.getActualRowAt(table.getModel(), table.rowAtPoint(e.getPoint()))); } }; table.setToolTipText(""); //necessary to force check for tooltip text table.setClearSelectionOnTableDataChanges(true); table.setOptimized(true); table.setColumnAutoResizable(true); table.setAutoResort(false); table.setRowHeight(20); table.setSortable(allowSort); table.setSortingEnabled(allowSort); table.setFocusable(selectionType != TableSelectionType.DISABLED); //table.setCellSelectionEnabled(allowSelection); table.setCellSelectionEnabled(selectionType == TableSelectionType.CELL); table.setRowSelectionAllowed(selectionType == TableSelectionType.ROW); table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); //column chooser TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table); installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer()); columnChooser = new ColumnChooser(table); installer.addTableHeaderPopupMenuCustomizer(columnChooser); AutoFilterTableHeader header = new AutoFilterTableHeader(table); header.setAutoFilterEnabled(true); header.setShowFilterIcon(true); header.setShowFilterName(true); table.setTableHeader(header); filterField = new QuickTableFilterField(model); if (allowPages) { filterField.setHintText("Search for anything on the page"); } else { filterField.setHintText("Search for anything"); } setLayout(new BorderLayout(3, 3)); fieldPanel = ViewUtil.getClearPanel(); if (allowSearch) { fieldPanel.add(filterField); } chooseColumnButton = new JButton("Columns"); chooseColumnButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { columnChooser.showDialog(); } }); helpButton = ViewUtil.getHelpButton("About Variant List", "Variants are sorted first by DNA ID, then by position. The list of variants within each page can be sorted by various fields by clicking the corresponding column name, but note that this will only sort the current page."); exportButton = new JButton("Export"); exportButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { ExportTable.exportTable(table); } catch (Exception ex) { LOG.error("Error while exporting.", ex); DialogUtils.displayException("MedSavant", "<HTML>A problem occurred while exporting.<BR>Make sure the output file is not already in use.</HTML>", ex); } } }); fieldPanel.add(helpButton); fieldPanel.add(chooseColumnButton); fieldPanel.add(exportButton); bottomPanel = ViewUtil.getClearPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS)); gotoFirst = niceButton(); gotoPrevious = niceButton(); gotoNext = niceButton(); gotoLast = niceButton(); gotoFirst.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.FIRST)); gotoPrevious.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.PREVIOUS)); gotoNext.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.NEXT)); gotoLast.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LAST)); gotoFirst.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToFirstPage(); } }); gotoPrevious.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToPreviousPage(); } }); gotoNext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToNextPage(); } }); gotoLast.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToLastPage(); } }); pageText = new JTextField(); ViewUtil.makeSmall(pageText); pageText.setColumns(5); pageText.setMaximumSize(new Dimension(50, 20)); pageText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { try { setPageNumber(Integer.parseInt(pageText.getText())); } catch (NumberFormatException ex) { setPageNumber(0); } } } }); amountLabel = new JLabel(); ViewUtil.makeSmall(amountLabel); bottomPanel.add(amountLabel); pageLabel1 = new JLabel("Page "); ViewUtil.makeSmall(pageLabel1); pageLabel2 = new JLabel(); ViewUtil.makeSmall(pageLabel2); bottomPanel.add(Box.createHorizontalGlue()); bottomPanel.add(gotoFirst); bottomPanel.add(gotoPrevious); strut(bottomPanel); bottomPanel.add(pageLabel1); bottomPanel.add(pageText); bottomPanel.add(pageLabel2); strut(bottomPanel); bottomPanel.add(gotoNext); bottomPanel.add(gotoLast); bottomPanel.add(Box.createHorizontalGlue()); strut(bottomPanel); JLabel perpageL = new JLabel("Per page:"); ViewUtil.makeSmall(perpageL); bottomPanel.add(perpageL); strut(bottomPanel); boolean hasDefaultRowsPerPage = true; if (rowsPerPageX == ROWSPERPAGE_1 || rowsPerPageX == ROWSPERPAGE_2 || rowsPerPageX == ROWSPERPAGE_3) { hasDefaultRowsPerPage = false; } ArrayList<Integer> rowsList = new ArrayList<Integer>(); rowsList.add(ROWSPERPAGE_1); rowsList.add(ROWSPERPAGE_2); rowsList.add(ROWSPERPAGE_3); Integer[] finalList = new Integer[3]; if (hasDefaultRowsPerPage) { rowsList.add(rowsPerPageX); Collections.sort(rowsList); } finalList = rowsList.toArray(finalList); rowsPerPageDropdown = new JComboBox(finalList); ViewUtil.makeSmall(rowsPerPageDropdown); rowsPerPageDropdown.setPrototypeDisplayValue(ROWSPERPAGE_3); if (hasDefaultRowsPerPage) { rowsPerPageDropdown.setSelectedIndex(rowsList.indexOf(rowsPerPageX)); } else { rowsPerPageDropdown.setSelectedIndex(1); } rowsPerPageDropdown.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); int rowsPerPage = (Integer) cb.getSelectedItem(); setNumRowsPerPage(rowsPerPage); } }); rowsPerPageDropdown.setPreferredSize(new Dimension(100, 25)); rowsPerPageDropdown.setMaximumSize(new Dimension(100, 25)); bottomPanel.add(rowsPerPageDropdown); setTableModel(data, columnNames, columnClasses); JPanel tablePanel = new JPanel(new BorderLayout(3, 3)); JScrollPane jsp = new JScrollPane(table); jsp.setBorder(null); tablePanel.add(jsp); if (allowSort) { add(fieldPanel, BorderLayout.NORTH); } if (allowPages) { add(bottomPanel, BorderLayout.SOUTH); } add(tablePanel, BorderLayout.CENTER); initEmpty(); }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
public void initComponentsManual() { attachmentPopupMenu = new JPopupMenu(); JMenuItem viewAttach = new JMenuItem("View Attachment"); viewAttach.setIcon(new ImageIcon(Frame.class.getResource("images/attach.png"))); viewAttach.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewAttachment();/*from ww w. j a v a 2 s . c o m*/ } }); attachmentPopupMenu.add(viewAttach); JMenuItem exportAttach = new JMenuItem("Export Attachment"); exportAttach.setIcon(new ImageIcon(Frame.class.getResource("images/report_disk.png"))); exportAttach.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportAttachment(); } }); attachmentPopupMenu.add(exportAttach); pageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true)); pageNumberField.setDocument(new MirthFieldConstraints(7, false, false, true)); advancedSearchPopup = new MessageBrowserAdvancedFilter(parent, this, "Advanced Search Filter", true, true); advancedSearchPopup.setVisible(false); LineBorder lineBorder = new LineBorder(new Color(0, 0, 0)); TitledBorder titledBorder = new TitledBorder("Current Search"); titledBorder.setBorder(lineBorder); lastSearchCriteriaPane.setBorder(titledBorder); lastSearchCriteriaPane.setBackground(Color.white); lastSearchCriteria.setBackground(Color.white); mirthDatePicker1.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { allDayCheckBox.setEnabled(mirthDatePicker1.getDate() != null || mirthDatePicker2.getDate() != null); mirthTimePicker1.setEnabled(mirthDatePicker1.getDate() != null && !allDayCheckBox.isSelected()); } }); mirthDatePicker2.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { allDayCheckBox.setEnabled(mirthDatePicker1.getDate() != null || mirthDatePicker2.getDate() != null); mirthTimePicker2.setEnabled(mirthDatePicker2.getDate() != null && !allDayCheckBox.isSelected()); } }); pageNumberField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_ENTER && pageGoButton.isEnabled()) { jumpToPageNumber(); } } }); if (!Arrays.asList("postgres", "oracle", "mysql").contains(PlatformUI.SERVER_DATABASE)) { regexTextSearchCheckBox.setEnabled(false); } this.addAncestorListener(new AncestorListener() { @Override public void ancestorAdded(AncestorEvent event) { } @Override public void ancestorMoved(AncestorEvent event) { } @Override public void ancestorRemoved(AncestorEvent event) { // Stop waiting for message browser requests when the message browser // is no longer being displayed parent.mirthClient.getServerConnection().abort(getAbortOperations()); // Clear the message cache when leaving the message browser. parent.messageBrowser.clearCache(); // Clear the table selection to prevent the selection listener from triggering multiple times while the model is being cleared deselectRows(); // Clear the records in the table tableModel.clear(); // Remove all columns for (TableColumn tableColumn : messageTreeTable.getColumns(true)) { messageTreeTable.removeColumn(tableColumn); } } }); }
From source file:com.cmsoftware.keyron.vista.admin.ActivarEmpleado.java
private void correoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_correoKeyTyped correo.setBackground(new Color(255, 255, 255)); if (KeyEvent.VK_ENTER == evt.getKeyChar()) { activarEmpleado();/*from ww w . j a v a 2 s. c o m*/ } else { labelError.setText(""); } }
From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java
/** * //from w w w . j av a 2 s. c o m */ protected void buildSpreadsheet() { this.setShowGrid(true); int numRows = model.getRowCount(); scrollPane = new JScrollPane(this, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final SpreadSheet ss = this; JButton cornerBtn = UIHelper.createIconBtn("Blank", IconManager.IconSize.Std16, "SelectAll", new ActionListener() { public void actionPerformed(ActionEvent ae) { ss.selectAll(); } }); cornerBtn.setEnabled(true); scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, cornerBtn); // Allows row and collumn selections to exit at the same time setCellSelectionEnabled(true); setRowSelectionAllowed(true); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); addMouseListener(new MouseAdapter() { /* (non-Javadoc) * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) */ @SuppressWarnings("synthetic-access") @Override public void mouseReleased(MouseEvent e) { // XXX For Java 5 Bug prevRowSelInx = getSelectedRow(); prevColSelInx = getSelectedColumn(); if (e.getClickCount() == 2) { int rowIndexStart = getSelectedRow(); int colIndexStart = getSelectedColumn(); ss.editCellAt(rowIndexStart, colIndexStart); if (ss.getEditorComponent() != null && ss.getEditorComponent() instanceof JTextComponent) { ss.getEditorComponent().requestFocus(); final JTextComponent txtComp = (JTextComponent) ss.getEditorComponent(); String txt = txtComp.getText(); FontMetrics fm = txtComp.getFontMetrics(txtComp.getFont()); int x = e.getPoint().x - ss.getEditorComponent().getBounds().x - 1; int prevWidth = 0; for (int i = 0; i < txt.length(); i++) { int width = fm.stringWidth(txt.substring(0, i)); int basePlusHalf = prevWidth + (int) (((width - prevWidth) / 2) + 0.5); //System.out.println(prevWidth + " X[" + x + "] " + width+" ["+txt.substring(0, i)+"] " + i + " " + basePlusHalf); //System.out.println(" X[" + x + "] " + prevWidth + " - "+ basePlusHalf+" - " + width+" ["+txt.substring(0, i)+"] " + i); if (x < width) { // Clearing the selection is needed for Window for some reason final int inx = i + (x <= basePlusHalf ? -1 : 0); SwingUtilities.invokeLater(new Runnable() { @SuppressWarnings("synthetic-access") public void run() { txtComp.setSelectionStart(0); txtComp.setSelectionEnd(0); txtComp.setCaretPosition(inx > 0 ? inx : 0); } }); break; } prevWidth = width; } } } } }); // Create a row-header to display row numbers. // This row-header is made of labels whose Borders, // Foregrounds, Backgrounds, and Fonts must be // the one used for the table column headers. // Also ensure that the row-header labels and the table // rows have the same height. //i have no idea WHY this has to be called. i rearranged //the table and find replace panel, // i started getting an array index out of //bounds on the column header ON MAC ONLY. //tried firing this off, first and it fixed the problem.//meg this.getModel().fireTableStructureChanged(); /* * Create the Row Header Panel */ rowHeaderPanel = new JPanel((LayoutManager) null); if (getColumnModel().getColumnCount() > 0) { TableColumn column = getColumnModel().getColumn(0); TableCellRenderer renderer = getTableHeader().getDefaultRenderer(); if (renderer == null) { renderer = column.getHeaderRenderer(); } Component cellRenderComp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, -1, 0); cellFont = cellRenderComp.getFont(); } else { cellFont = (new JLabel()).getFont(); } // Calculate Row Height cellBorder = (Border) UIManager.getDefaults().get("TableHeader.cellBorder"); Insets insets = cellBorder.getBorderInsets(tableHeader); FontMetrics metrics = getFontMetrics(cellFont); rowHeight = insets.bottom + metrics.getHeight() + insets.top; rowLabelWidth = metrics.stringWidth("9999") + insets.right + insets.left; Dimension dim = new Dimension(rowLabelWidth, rowHeight * numRows); rowHeaderPanel.setPreferredSize(dim); // need to call this when no layout manager is used. rhCellMouseAdapter = new RHCellMouseAdapter(this); // Adding the row header labels for (int ii = 0; ii < numRows; ii++) { addRow(ii, ii + 1, false); } JViewport viewPort = new JViewport(); dim.height = rowHeight * numRows; viewPort.setViewSize(dim); viewPort.setView(rowHeaderPanel); scrollPane.setRowHeader(viewPort); // Experimental from the web, but I think it does the trick. addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (!ss.isEditing() && !e.isActionKey() && !e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && e.getKeyCode() != KeyEvent.VK_SHIFT && e.getKeyCode() != KeyEvent.VK_TAB && e.getKeyCode() != KeyEvent.VK_ENTER) { log.error("Grabbed the event as input"); int rowIndexStart = getSelectedRow(); int colIndexStart = getSelectedColumn(); if (rowIndexStart == -1 || colIndexStart == -1) return; ss.editCellAt(rowIndexStart, colIndexStart); Component c = ss.getEditorComponent(); if (c instanceof JTextComponent) ((JTextComponent) c).setText(""); } } }); resizeAndRepaint(); // Taken from a JavaWorld Example (But it works) KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); Action ssAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { SpreadSheet.this.actionPerformed(e); } }; getInputMap().put(cut, "Cut"); getActionMap().put("Cut", ssAction); getInputMap().put(copy, "Copy"); getActionMap().put("Copy", ssAction); getInputMap().put(paste, "Paste"); getActionMap().put("Paste", ssAction); ((JMenuItem) UIRegistry.get(UIRegistry.COPY)).addActionListener(this); ((JMenuItem) UIRegistry.get(UIRegistry.CUT)).addActionListener(this); ((JMenuItem) UIRegistry.get(UIRegistry.PASTE)).addActionListener(this); setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED); }
From source file:com.cmsoftware.keyron.vista.admin.ActivarEmpleado.java
private void claveKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_claveKeyTyped clave.setBackground(new Color(255, 255, 255)); if (KeyEvent.VK_ENTER == evt.getKeyChar()) { activarEmpleado();//from ww w . ja v a2 s . c om } else { labelError.setText(""); } }
From source file:storybook.toolkit.swing.SwingUtil.java
public static void addCtrlEnterAction(JComponent comp, AbstractAction action) { InputMap inputMap = comp.getInputMap(); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), action); }
From source file:org.jas.gui.LoginWindow.java
private void initialize() { getFrame().add(getPanel());/*from w w w .j a v a 2 s .co m*/ getFrame().setVisible(false); getSendButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configurator.getViewEngine().sendValueAction(Actions.LOGIN, new User(usernameTextfield.getText(), new String(passwordTextfield.getPassword()))); } }); getSendButton().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { configurator.getViewEngine().sendValueAction(Actions.LOGIN, new User(usernameTextfield.getText(), new String(passwordTextfield.getPassword()))); } }); getPasswordTextfield().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { configurator.getViewEngine().sendValueAction(Actions.LOGIN, new User(usernameTextfield.getText(), new String(passwordTextfield.getPassword()))); } } }); }
From source file:client.InterfaceJeu.java
private void txtFieldChatEcrKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtFieldChatEcrKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { c.ecrireMessage("chat::" + txtFieldChatEcr.getText()); txtFieldChatEcr.setText(""); }//from www . j av a2s. c o m }
From source file:org.yccheok.jstock.gui.AutoCompleteJComboBox.java
private KeyAdapter getEditorComponentKeyAdapter() { return new KeyAdapter() { @Override// w w w . j a v a2 s.c o m public void keyReleased(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { // We are no longer busy. busySubject.notify(AutoCompleteJComboBox.this, false); StockInfo lastEnteredStockInfo = null; DispType lastEnteredDispType = null; if (AutoCompleteJComboBox.this.getItemCount() > 0) { int index = AutoCompleteJComboBox.this.getSelectedIndex(); if (index == -1) { Object object = AutoCompleteJComboBox.this.getItemAt(0); if (object instanceof StockInfo) { lastEnteredStockInfo = (StockInfo) object; } else if (object instanceof DispType) { lastEnteredDispType = (DispType) object; } } else { Object object = AutoCompleteJComboBox.this.getItemAt(index); if (object instanceof StockInfo) { lastEnteredStockInfo = (StockInfo) object; } else if (object instanceof DispType) { lastEnteredDispType = (DispType) object; } } } else { // If item count is 0, this means stockInfoDatabase // unable provide us any result based on user query. I // suspect we still need to below code, as // stockInfoDatabase will just return null. However, it // should make no harm at this moment. if (AutoCompleteJComboBox.this.stockInfoDatabase != null) { final Object object = AutoCompleteJComboBox.this.getEditor().getItem(); if (object instanceof String) { String lastEnteredString = ((String) object).trim(); lastEnteredStockInfo = AutoCompleteJComboBox.this.stockInfoDatabase .searchStockInfo(lastEnteredString); } else { assert (false); } } } AutoCompleteJComboBox.this.removeAllItems(); if (lastEnteredStockInfo != null) { AutoCompleteJComboBox.this.stockInfoSubject.notify(AutoCompleteJComboBox.this, lastEnteredStockInfo); } else if (lastEnteredDispType != null) { AutoCompleteJComboBox.this.dispSubject.notify(AutoCompleteJComboBox.this, lastEnteredDispType); } else { // Do nothing. } return; } /* if(KeyEvent.VK_ENTER == e.getKeyCode()) */ // If user removes item from text field, we will hidePopup and // removeAllItems. Please refer DocumentListener.handle, on why // don't we handle hidePopup and removeAllItems there. final Object object = AutoCompleteJComboBox.this.getEditor().getItem(); if (object == null || object.toString().length() <= 0) { AutoCompleteJComboBox.this.hidePopup(); AutoCompleteJComboBox.this.removeAllItems(); } } /* public void keyReleased(KeyEvent e) */ }; }
From source file:org.apache.cayenne.modeler.CayenneModelerFrame.java
/** Initializes main toolbar. */ protected void initToolbar() { JToolBar toolBar = new JToolBar(); toolBar.add(getAction(NewProjectAction.class).buildButton()); toolBar.add(getAction(OpenProjectAction.class).buildButton()); toolBar.add(getAction(SaveAction.class).buildButton()); toolBar.addSeparator();/* w w w . j a v a2 s. com*/ toolBar.add(getAction(RemoveAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CutAction.class).buildButton()); toolBar.add(getAction(CopyAction.class).buildButton()); toolBar.add(getAction(PasteAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(UndoAction.class).buildButton()); toolBar.add(getAction(RedoAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CreateNodeAction.class).buildButton()); toolBar.add(getAction(CreateDataMapAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CreateDbEntityAction.class).buildButton()); toolBar.add(getAction(CreateProcedureAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(CreateObjEntityAction.class).buildButton()); toolBar.add(getAction(CreateEmbeddableAction.class).buildButton()); toolBar.add(getAction(CreateQueryAction.class).buildButton()); toolBar.addSeparator(); toolBar.add(getAction(NavigateBackwardAction.class).buildButton()); toolBar.add(getAction(NavigateForwardAction.class).buildButton()); JPanel east = new JPanel(new BorderLayout()); // is used to place search feature // components the most right on a // toolbar final JTextField findField = new JTextField(10); findField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_ENTER) { findField.setBackground(Color.white); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } }); findField.setAction(getAction(FindAction.class)); JLabel findLabel = new JLabel("Search:"); findLabel.setLabelFor(findField); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event instanceof KeyEvent) { if (((KeyEvent) event).getModifiers() == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_F) { findField.requestFocus(); } } } }, AWTEvent.KEY_EVENT_MASK); JPanel box = new JPanel(); // is used to place label and text field one after // another box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS)); box.add(findLabel); box.add(findField); east.add(box, BorderLayout.EAST); toolBar.add(east); getContentPane().add(toolBar, BorderLayout.NORTH); }