List of usage examples for java.awt.event KeyEvent getKeyCode
public int getKeyCode()
From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java
public NodeList(final boolean modal, final boolean showAllNodes, final boolean searchInAllMaps) { // this.modeController = modeController; // controller = modeController.getController(); this.modal = modal; this.showAllNodes = showAllNodes; this.searchInAllMaps = searchInAllMaps; mFilterTextSearchField = new JComboBox(); mFilterTextSearchField.setEditable(true); final FilterTextDocumentListener listener = new FilterTextDocumentListener(); mFilterTextSearchField.addActionListener(listener); final JTextComponent editorComponent = (JTextComponent) mFilterTextSearchField.getEditor() .getEditorComponent();//from w w w . j av a 2 s .co m editorComponent.getDocument().addDocumentListener(listener); mFilterTextSearchField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent pEvent) { if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) { mFilterTextReplaceField.requestFocusInWindow(); } } }); mFilterTextReplaceField = new JComboBox(); mFilterTextReplaceField.setEditable(true); mFilterTextReplaceField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent pEvent) { if (pEvent.getKeyCode() == KeyEvent.VK_DOWN) { tableView.requestFocusInWindow(); } else if (pEvent.getKeyCode() == KeyEvent.VK_UP) { mFilterTextSearchField.requestFocusInWindow(); } } }); useRegexInReplace = new JCheckBox(); useRegexInFind = new JCheckBox(); useRegexInFind.addChangeListener(listener); matchCase = new JCheckBox(); matchCase.addChangeListener(listener); final MapChangeListener mapChangeListener = new MapChangeListener(); final ModeController modeController = Controller.getCurrentModeController(); final MapController mapController = modeController.getMapController(); mapController.addMapChangeListener(mapChangeListener); mapController.addNodeChangeListener(mapChangeListener); Controller.getCurrentController().getMapViewManager().addMapSelectionListener(mapChangeListener); }
From source file:Report_PRCR_New_ETF_Excel_File_Generator.java
private void monthfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_monthfieldKeyPressed if (monthfield.getText().equals("Jan")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Dec"); int yr = Integer.parseInt(yearfield.getText()); yearfield.setText("" + (yr - 1)); monthfield.selectAll();//from w ww.java 2s . co m } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Feb"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Feb")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Jan"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Mar"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Mar")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Feb"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Apr"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Apr")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Mar"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("May"); monthfield.selectAll(); } } else if (monthfield.getText().equals("May")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Apr"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Jun"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Jun")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("May"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Jul"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Jul")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Jun"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Aug"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Aug")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Jul"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Sep"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Sep")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Aug"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Oct"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Oct")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Sep"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Nov"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Nov")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Oct"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Dec"); monthfield.selectAll(); } } else if (monthfield.getText().equals("Dec")) { if (evt.getKeyCode() == KeyEvent.VK_DOWN) { monthfield.setText("Nov"); int yr = Integer.parseInt(yearfield.getText()); monthfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_UP) { monthfield.setText("Jan"); int yr = Integer.parseInt(yearfield.getText()); yearfield.setText("" + (yr + 1)); monthfield.selectAll(); } } if (evt.getKeyCode() == KeyEvent.VK_LEFT) { // dayfield.requestFocus(); // dayfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_RIGHT) { yearfield.requestFocus(); yearfield.selectAll(); } if (evt.getKeyCode() == KeyEvent.VK_ENTER) { ////// ChaNGE focus on enter//////////////// // dayfield2.requestFocus(); // dayfield2.selectAll(); } }
From source file:com.kenai.redminenb.query.RedmineQueryController.java
@Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() != KeyEvent.VK_ENTER) { return;//from ww w .j a va 2 s . co m } if (e.getSource() == queryPanel.categoryList || e.getSource() == queryPanel.versionList || e.getSource() == queryPanel.statusList || e.getSource() == queryPanel.resolutionList || e.getSource() == queryPanel.priorityList || e.getSource() == queryPanel.assigneeList) { onRefresh(); } }
From source file:org.nekorp.workflow.desktop.view.DatosClienteView.java
private void nombreClienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nombreClienteKeyPressed if (evt.getKeyCode() == KeyEvent.VK_UP) { if (this.search.getModel().getSize() > 0) { if (this.search.isSelectionEmpty()) { //si no hay nada seleccionado int nuevoIndex = this.search.getModel().getSize() - 1; this.search.setSelectedIndex(nuevoIndex); calculaNuevaPosicionScrollUp(nuevoIndex); } else { int nuevoIndex = this.search.getSelectedIndex() - 1; if (nuevoIndex < 0) { nuevoIndex = this.search.getModel().getSize() - 1; }//from w w w.j ava 2 s . com this.search.setSelectedIndex(nuevoIndex); calculaNuevaPosicionScrollUp(nuevoIndex); } } } if (evt.getKeyCode() == KeyEvent.VK_DOWN) { if (this.search.getModel().getSize() > 0) { if (this.search.isSelectionEmpty()) { //si no hay nada seleccionado this.search.setSelectedIndex(0); calculaNuevaPosicionScrollDown(0); } else { int nuevoIndex = this.search.getSelectedIndex() + 1; if (nuevoIndex > this.search.getModel().getSize() - 1) { nuevoIndex = 0; } this.search.setSelectedIndex(nuevoIndex); calculaNuevaPosicionScrollDown(nuevoIndex); } } } if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) { this.searchScroll.setVisible(false); } }
From source file:com.peter.mavenrunner.MavenRunnerTopComponent.java
private void projectTreeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_projectTreeKeyReleased if (evt.getKeyCode() == 525) { // treePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); try {/*from w w w .j a v a 2 s .c o m*/ Robot robot = new Robot(); robot.mousePress(InputEvent.BUTTON3_MASK); robot.mouseRelease(InputEvent.BUTTON3_MASK); } catch (AWTException ex) { Exceptions.printStackTrace(ex); } } }
From source file:savant.view.swing.NavigationBar.java
NavigationBar() { this.setOpaque(false); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); String buttonStyle = "segmentedCapsule"; String shortcutMod = MiscUtils.MAC ? "Cmd" : "Ctrl"; add(getRigidPadding());//from w w w . j a v a 2s . co m JButton loadGenomeButton = (JButton) add(new JButton("")); loadGenomeButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.GENOME)); loadGenomeButton.setToolTipText("Load or change genome"); loadGenomeButton.setFocusable(false); loadGenomeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Savant.getInstance().showOpenGenomeDialog(); } }); loadGenomeButton.putClientProperty("JButton.buttonType", buttonStyle); loadGenomeButton.putClientProperty("JButton.segmentPosition", "first"); loadGenomeButton.setPreferredSize(ICON_SIZE); loadGenomeButton.setMinimumSize(ICON_SIZE); loadGenomeButton.setMaximumSize(ICON_SIZE); JButton loadTrackButton = (JButton) add(new JButton("")); loadTrackButton.setFocusable(false); loadTrackButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK)); loadTrackButton.setToolTipText("Load a track"); loadTrackButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Savant.getInstance().openTrack(); } }); loadTrackButton.putClientProperty("JButton.buttonType", buttonStyle); loadTrackButton.putClientProperty("JButton.segmentPosition", "last"); loadTrackButton.setPreferredSize(ICON_SIZE); loadTrackButton.setMinimumSize(ICON_SIZE); loadTrackButton.setMaximumSize(ICON_SIZE); if (!Savant.getInstance().isStandalone()) { add(loadGenomeButton); add(loadTrackButton); add(getRigidPadding()); add(getRigidPadding()); } else { loadGenomeButton.setVisible(false); loadTrackButton.setVisible(false); } JLabel rangeText = new JLabel("Location "); add(rangeText); String[] a = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " }; locationField = new JComboBox(a); locationField.setEditable(true); locationField.setRenderer(new ReferenceListRenderer()); // When the item is chosen from the menu, navigate to the given feature/reference. locationField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (!currentlyPopulating) { if (ae.getActionCommand().equals("comboBoxChanged")) { // Assumes that combo-box items created by populateCombo() are of the form "GENE (chrX:1-1000)". String itemText = locationField.getSelectedItem().toString(); int lastBracketPos = itemText.lastIndexOf('('); if (lastBracketPos > 0) { itemText = itemText.substring(lastBracketPos + 1, itemText.length() - 1); } setRangeFromText(itemText); } } } }); // When the combo-box is popped open, we may want to repopulate the menu. locationField.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent pme) { String text = (String) locationField.getEditor().getItem(); if (!text.equals(lastPoppedUp)) { try { // Building the menu could take a while. setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); populateCombo(); } finally { setCursor(Cursor.getDefaultCursor()); } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) { } @Override public void popupMenuCanceled(PopupMenuEvent pme) { } }); // Add our special keystroke-handling to the JComboBox' text-field. // We have to turn off default tab-handling so that tab can pop up our list. Component textField = locationField.getEditor().getEditorComponent(); textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET); textField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_TAB) { locationField.showPopup(); } else if (evt.getModifiers() == KeyEvent.SHIFT_MASK) { switch (evt.getKeyCode()) { case KeyEvent.VK_LEFT: locationController.shiftRangeLeft(); evt.consume(); break; case KeyEvent.VK_RIGHT: locationController.shiftRangeRight(); evt.consume(); break; case KeyEvent.VK_UP: locationController.zoomIn(); evt.consume(); break; case KeyEvent.VK_DOWN: locationController.zoomOut(); evt.consume(); break; case KeyEvent.VK_HOME: locationController.shiftRangeFarLeft(); evt.consume(); break; case KeyEvent.VK_END: locationController.shiftRangeFarRight(); evt.consume(); break; } } } }); add(locationField); locationField.setToolTipText("Current display range"); locationField.setPreferredSize(LOCATION_SIZE); locationField.setMaximumSize(LOCATION_SIZE); locationField.setMinimumSize(LOCATION_SIZE); add(getRigidPadding()); JButton goButton = (JButton) add(new JButton(" Go ")); goButton.putClientProperty("JButton.buttonType", buttonStyle); goButton.putClientProperty("JButton.segmentPosition", "only"); goButton.setToolTipText("Go to specified range (Enter)"); goButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRangeFromText(locationField.getEditor().getItem().toString()); } }); add(getRigidPadding()); JLabel l = new JLabel("Length: "); add(l); lengthLabel = (JLabel) add(new JLabel()); lengthLabel.setToolTipText("Length of the current range"); lengthLabel.setPreferredSize(LENGTH_SIZE); lengthLabel.setMaximumSize(LENGTH_SIZE); lengthLabel.setMinimumSize(LENGTH_SIZE); add(Box.createGlue()); double screenwidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); JButton afterGo = null; //if (screenwidth > 800) { final JButton undoButton = (JButton) add(new JButton("")); afterGo = undoButton; undoButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UNDO)); undoButton.setToolTipText("Undo range change (" + shortcutMod + "+Z)"); undoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.undoLocationChange(); } }); undoButton.putClientProperty("JButton.buttonType", buttonStyle); undoButton.putClientProperty("JButton.segmentPosition", "first"); undoButton.setPreferredSize(ICON_SIZE); undoButton.setMinimumSize(ICON_SIZE); undoButton.setMaximumSize(ICON_SIZE); final JButton redo = (JButton) add(new JButton("")); redo.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.REDO)); redo.setToolTipText("Redo range change (" + shortcutMod + "+Y)"); redo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.redoLocationChange(); } }); redo.putClientProperty("JButton.buttonType", buttonStyle); redo.putClientProperty("JButton.segmentPosition", "last"); redo.setPreferredSize(ICON_SIZE); redo.setMinimumSize(ICON_SIZE); redo.setMaximumSize(ICON_SIZE); //} add(getRigidPadding()); add(getRigidPadding()); final JButton zoomInButton = (JButton) add(new JButton()); if (afterGo == null) { afterGo = zoomInButton; } zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.putClientProperty("JButton.buttonType", buttonStyle); zoomInButton.putClientProperty("JButton.segmentPosition", "first"); zoomInButton.setPreferredSize(ICON_SIZE); zoomInButton.setMinimumSize(ICON_SIZE); zoomInButton.setMaximumSize(ICON_SIZE); zoomInButton.setToolTipText("Zoom in (Shift+Up)"); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.zoomIn(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"), new NameValuePair("navigation-direction", "in"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton zoomOut = (JButton) add(new JButton("")); zoomOut.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOut.setToolTipText("Zoom out (Shift+Down)"); zoomOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.zoomOut(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"), new NameValuePair("navigation-direction", "out"), new NameValuePair("navigation-modality", "navbar") }); } }); zoomOut.putClientProperty("JButton.buttonType", buttonStyle); zoomOut.putClientProperty("JButton.segmentPosition", "last"); zoomOut.setPreferredSize(ICON_SIZE); zoomOut.setMinimumSize(ICON_SIZE); zoomOut.setMaximumSize(ICON_SIZE); add(getRigidPadding()); add(getRigidPadding()); final JButton shiftFarLeft = (JButton) add(new JButton()); shiftFarLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARLEFT)); shiftFarLeft.putClientProperty("JButton.buttonType", buttonStyle); shiftFarLeft.putClientProperty("JButton.segmentPosition", "first"); shiftFarLeft.setToolTipText("Move to the beginning of the genome (Shift+Home)"); shiftFarLeft.setPreferredSize(ICON_SIZE); shiftFarLeft.setMinimumSize(ICON_SIZE); shiftFarLeft.setMaximumSize(ICON_SIZE); shiftFarLeft.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeFarLeft(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "left"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftLeft = (JButton) add(new JButton()); shiftLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_LEFT)); shiftLeft.putClientProperty("JButton.buttonType", buttonStyle); shiftLeft.putClientProperty("JButton.segmentPosition", "middle"); shiftLeft.setToolTipText("Move left (Shift+Left)"); shiftLeft.setPreferredSize(ICON_SIZE); shiftLeft.setMinimumSize(ICON_SIZE); shiftLeft.setMaximumSize(ICON_SIZE); shiftLeft.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeLeft(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "left"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftRight = (JButton) add(new JButton()); shiftRight.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_RIGHT)); shiftRight.putClientProperty("JButton.buttonType", buttonStyle); shiftRight.putClientProperty("JButton.segmentPosition", "middle"); shiftRight.setToolTipText("Move right (Shift+Right)"); shiftRight.setPreferredSize(ICON_SIZE); shiftRight.setMinimumSize(ICON_SIZE); shiftRight.setMaximumSize(ICON_SIZE); shiftRight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeRight(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "right"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftFarRight = (JButton) add(new JButton()); shiftFarRight .setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARRIGHT)); shiftFarRight.putClientProperty("JButton.buttonType", buttonStyle); shiftFarRight.putClientProperty("JButton.segmentPosition", "last"); shiftFarRight.setToolTipText("Move to the end of the genome (Shift+End)"); shiftFarRight.setPreferredSize(ICON_SIZE); shiftFarRight.setMinimumSize(ICON_SIZE); shiftFarRight.setMaximumSize(ICON_SIZE); shiftFarRight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeFarRight(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "right"), new NameValuePair("navigation-modality", "navbar") }); } }); add(getRigidPadding()); locationController.addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { updateLocation(event.getReference(), (Range) event.getRange()); } }); // When the genome changes, we may need to invalidate our menu. GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { lastPoppedUp = "INVALID"; } }); this.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent ce) { int width = ce.getComponent().getWidth(); undoButton.setVisible(true); redo.setVisible(true); zoomInButton.setVisible(true); zoomOut.setVisible(true); shiftFarLeft.setVisible(true); shiftLeft.setVisible(true); shiftRight.setVisible(true); shiftFarRight.setVisible(true); // hide some components if the window isn't wide enough if (width < 1200) { undoButton.setVisible(false); redo.setVisible(false); } if (width < 1000) { shiftFarLeft.setVisible(false); shiftFarRight.setVisible(false); shiftRight.putClientProperty("JButton.segmentPosition", "last"); shiftLeft.putClientProperty("JButton.segmentPosition", "first"); } else { shiftRight.putClientProperty("JButton.segmentPosition", "middle"); shiftLeft.putClientProperty("JButton.segmentPosition", "middle"); } } public void componentMoved(ComponentEvent ce) { } @Override public void componentShown(ComponentEvent ce) { } @Override public void componentHidden(ComponentEvent ce) { } }); }
From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java
/** Initializes the components composing the display. */ private void initComponents() { usersBox = new JComboBox(); groupsBox = createGroupBox();//from w ww . j av a 2 s. co m scopes = new HashMap<Integer, JCheckBox>(model.getNodes().size()); types = new HashMap<Integer, JCheckBox>(model.getTypes().size()); IconManager icons = IconManager.getInstance(); fromDate = UIUtilities.createDatePicker(true, EditorUtil.DATE_PICKER_FORMAT); fromDate.setBackground(UIUtilities.BACKGROUND_COLOR); fromDate.addPropertyChangeListener("date", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Date d = (Date) evt.getNewValue(); if (d != null) { if (d.after(new Date())) { UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier(); un.notifyWarning("Invalid Date", "Selecting a future 'From' date doesn't make any sense."); fromDate.setDate(null); } if (toDate.getDate() != null && d.after(toDate.getDate())) { UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier(); un.notifyWarning("Invalid Date", "Cannot set a 'From' date which is more recent than the 'To' date."); fromDate.setDate(null); } } } }); fromDate.setToolTipText(DATE_TOOLTIP); toDate = UIUtilities.createDatePicker(true, EditorUtil.DATE_PICKER_FORMAT); toDate.setBackground(UIUtilities.BACKGROUND_COLOR); toDate.setToolTipText(DATE_TOOLTIP); toDate.addPropertyChangeListener("date", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Date d = (Date) evt.getNewValue(); if (d != null) { if (fromDate.getDate() != null && d.before(fromDate.getDate())) { UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier(); un.notifyWarning("Invalid Date", "Cannot set a 'To' date which is prior to the 'From' date."); toDate.setDate(null); } } } }); clearDate = new JButton(icons.getIcon(IconManager.CLOSE)); clearDate.setToolTipText("Reset the dates"); UIUtilities.unifiedButtonLookAndFeel(clearDate); clearDate.setBackground(UIUtilities.BACKGROUND_COLOR); clearDate.setActionCommand("" + SearchComponent.RESET_DATE); clearDate.addActionListener(model); fullTextArea = new JTextField(AREA_COLUMNS); fullTextArea.addKeyListener(new KeyAdapter() { /** Finds the phrase. */ public void keyPressed(KeyEvent e) { Object source = e.getSource(); if (source != fullTextArea) return; switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: model.search(); } } }); helpBasicButton = new JButton(icons.getIcon(IconManager.HELP)); helpBasicButton.setToolTipText("Search Tips."); helpBasicButton.setBackground(UIUtilities.BACKGROUND_COLOR); UIUtilities.unifiedButtonLookAndFeel(helpBasicButton); helpBasicButton.addActionListener(model); helpBasicButton.setActionCommand("" + SearchComponent.HELP); SearchContext ctx = model.getSearchContext(); if (ctx == null) return; }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java
private JTextField getJTextFieldCreatorEmail() { if (jTextFieldCreatorEmail == null) { jTextFieldCreatorEmail = new JTextField(); jTextFieldCreatorEmail.setPreferredSize(new Dimension(200, 22)); jTextFieldCreatorEmail.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (jTextFieldCreatorEmail.getText().length() == 0) { jTextFieldCreatorEmail.requestFocusInWindow(); } else { getJTextFieldOrganizationName().requestFocusInWindow(); }/*from w ww.j a v a 2 s . c o m*/ } } }); jTextFieldCreatorEmail.setText(LoginSessionEnt.getInstance().getUserID()); } return jTextFieldCreatorEmail; }
From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java
private void actionModifierAxe(MouseEvent e, final int index) { if (index == -1) return;/* w ww . j a v a 2 s. c om*/ Component comp = (Component) e.getSource(); JFrame frame = (JFrame) SwingUtilities.getRoot(comp); this.windowChangeNom = new JWindow(frame); Container container = this.windowChangeNom.getContentPane(); container.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); c.insets = new Insets(0, 0, 0, 0); c.weightx = 1; this.editedAxeIndex = index; this.text = new JTextField(" " + this.tabAxes.getTitleAt(index) + " "); this.text.setEditable(true); container.add(this.text, c); this.text.setBorder(null); // text.setBackground(this.tabAxes.getBackground()); this.text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_ENTER) { validAxeText(); } } }); this.windowChangeNom.pack(); int ecartY = this.tabAxes.getBoundsAt(index).height - this.text.getBounds().height + 2; int ecartX = this.tabAxes.getBoundsAt(index).width - this.text.getBounds().width; this.windowChangeNom.setLocation( comp.getLocationOnScreen().x + this.tabAxes.getBoundsAt(index).getLocation().x + ecartX / 2, comp.getLocationOnScreen().y + this.tabAxes.getBoundsAt(index).getLocation().y + ecartY / 2); this.windowChangeNom.setVisible(true); }
From source file:EventTestPane.java
/** * Display keyboard events./*from w w w . j ava2s.c o m*/ * * Note that there are three distinct types of key events, and that key * events are reported by key code and/or Unicode character. KEY_PRESSED and * KEY_RELEASED events are generated for all key strokes. KEY_TYPED events * are only generated when a key stroke produces a Unicode character; these * events do not report a key code. If isActionKey() returns true, then the * key event reports only a key code, because the key that was pressed or * released (such as a function key) has no corresponding Unicode character. * Key codes can be interpreted by using the many VK_ constants defined by * the KeyEvent class, or they can be converted to strings using the static * getKeyText() method as we do here. */ public void processKeyEvent(KeyEvent e) { String eventtype, modifiers, code, character; switch (e.getID()) { case KeyEvent.KEY_PRESSED: eventtype = "KEY_PRESSED"; break; case KeyEvent.KEY_RELEASED: eventtype = "KEY_RELEASED"; break; case KeyEvent.KEY_TYPED: eventtype = "KEY_TYPED"; break; default: eventtype = "UNKNOWN"; } // Convert the list of modifier keys to a string modifiers = KeyEvent.getKeyModifiersText(e.getModifiers()); // Get string and numeric versions of the key code, if any. if (e.getID() == KeyEvent.KEY_TYPED) code = ""; else code = "Code=" + KeyEvent.getKeyText(e.getKeyCode()) + " (" + e.getKeyCode() + ")"; // Get string and numeric versions of the Unicode character, if any. if (e.isActionKey()) character = ""; else character = "Character=" + e.getKeyChar() + " (Unicode=" + ((int) e.getKeyChar()) + ")"; // Display it all. showLine(eventtype + ": " + modifiers + " " + code + " " + character); }