List of usage examples for java.awt.event KeyEvent VK_UP
int VK_UP
To view the source code for java.awt.event KeyEvent VK_UP.
Click Source Link
From source file:org.freeplane.view.swing.features.time.mindmapmode.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 a v a2 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) { timeTable.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:net.sf.jabref.groups.GroupSelector.java
/** * The first element for each group defines which field to use for the quicksearch. The next two define the name and * regexp for the group.//from ww w. ja v a 2 s .co m */ public GroupSelector(JabRefFrame frame, SidePaneManager manager) { super(manager, IconTheme.JabRefIcon.TOGGLE_GROUPS.getIcon(), Localization.lang("Groups")); this.groupsRoot = new GroupTreeNode(new AllEntriesGroup()); this.frame = frame; hideNonHits = new JRadioButtonMenuItem(Localization.lang("Hide non-hits"), !Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS)); grayOut = new JRadioButtonMenuItem(Localization.lang("Gray out non-hits"), Globals.prefs.getBoolean(JabRefPreferences.GRAY_OUT_NON_HITS)); ButtonGroup nonHits = new ButtonGroup(); nonHits.add(hideNonHits); nonHits.add(grayOut); floatCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS, floatCb.isSelected()); } }); andCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, andCb.isSelected()); } }); invCb.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS, invCb.isSelected()); } }); showOverlappingGroups.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING, showOverlappingGroups.isSelected()); if (!showOverlappingGroups.isSelected()) { groupsTree.setHighlight2Cells(null); } } }); select.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SELECT_MATCHES, select.isSelected()); } }); grayOut.addChangeListener( event -> Globals.prefs.putBoolean(JabRefPreferences.GRAY_OUT_NON_HITS, grayOut.isSelected())); JRadioButtonMenuItem highlCb = new JRadioButtonMenuItem(Localization.lang("Highlight"), false); if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_FLOAT_SELECTIONS)) { floatCb.setSelected(true); highlCb.setSelected(false); } else { highlCb.setSelected(true); floatCb.setSelected(false); } JRadioButtonMenuItem orCb = new JRadioButtonMenuItem(Localization.lang("Union"), false); if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_INTERSECT_SELECTIONS)) { andCb.setSelected(true); orCb.setSelected(false); } else { orCb.setSelected(true); andCb.setSelected(false); } showNumberOfElements.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Globals.prefs.putBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS, showNumberOfElements.isSelected()); if (groupsTree != null) { groupsTree.invalidate(); groupsTree.validate(); groupsTree.repaint(); } } }); autoAssignGroup.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { Globals.prefs.putBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP, autoAssignGroup.isSelected()); } }); invCb.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_INVERT_SELECTIONS)); showOverlappingGroups.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_OVERLAPPING)); select.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SELECT_MATCHES)); editModeIndicator = Globals.prefs.getBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE); editModeCb.setSelected(editModeIndicator); showNumberOfElements.setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS)); autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP)); openset.setMargin(new Insets(0, 0, 0, 0)); settings.add(andCb); settings.add(orCb); settings.addSeparator(); settings.add(invCb); settings.addSeparator(); settings.add(select); settings.addSeparator(); settings.add(editModeCb); settings.addSeparator(); settings.add(grayOut); settings.add(hideNonHits); settings.addSeparator(); settings.add(showOverlappingGroups); settings.addSeparator(); settings.add(showNumberOfElements); settings.add(autoAssignGroup); // settings.add(moreRow); // settings.add(lessRow); openset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!settings.isVisible()) { JButton src = (JButton) e.getSource(); showNumberOfElements .setSelected(Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS)); autoAssignGroup.setSelected(Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP)); settings.show(src, 0, openset.getHeight()); } } }); JButton expand = new JButton(IconTheme.JabRefIcon.ADD_ROW.getSmallIcon()); expand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) + 1; groupsTree.setVisibleRowCount(i); groupsTree.revalidate(); groupsTree.repaint(); GroupSelector.this.revalidate(); GroupSelector.this.repaint(); Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i); LOGGER.info("Height: " + GroupSelector.this.getHeight() + "; Preferred height: " + GroupSelector.this.getPreferredSize().getHeight()); } }); JButton reduce = new JButton(IconTheme.JabRefIcon.REMOVE_ROW.getSmallIcon()); reduce.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = Globals.prefs.getInt(JabRefPreferences.GROUPS_VISIBLE_ROWS) - 1; if (i < 1) { i = 1; } groupsTree.setVisibleRowCount(i); groupsTree.revalidate(); groupsTree.repaint(); GroupSelector.this.revalidate(); // _panel.sidePaneManager.revalidate(); GroupSelector.this.repaint(); Globals.prefs.putInt(JabRefPreferences.GROUPS_VISIBLE_ROWS, i); } }); editModeCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editModeIndicator = editModeCb.getState(); updateBorder(editModeIndicator); Globals.prefs.putBoolean(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE, editModeIndicator); } }); int butSize = newButton.getIcon().getIconHeight() + 5; Dimension butDim = new Dimension(butSize, butSize); //Dimension butDimSmall = new Dimension(20, 20); newButton.setPreferredSize(butDim); newButton.setMinimumSize(butDim); refresh.setPreferredSize(butDim); refresh.setMinimumSize(butDim); JButton helpButton = new HelpAction(Localization.lang("Help on groups"), HelpFiles.groupsHelp) .getHelpButton(); helpButton.setPreferredSize(butDim); helpButton.setMinimumSize(butDim); autoGroup.setPreferredSize(butDim); autoGroup.setMinimumSize(butDim); openset.setPreferredSize(butDim); openset.setMinimumSize(butDim); expand.setPreferredSize(butDim); expand.setMinimumSize(butDim); reduce.setPreferredSize(butDim); reduce.setMinimumSize(butDim); Insets butIns = new Insets(0, 0, 0, 0); helpButton.setMargin(butIns); reduce.setMargin(butIns); expand.setMargin(butIns); openset.setMargin(butIns); newButton.addActionListener(this); refresh.addActionListener(this); andCb.addActionListener(this); orCb.addActionListener(this); invCb.addActionListener(this); showOverlappingGroups.addActionListener(this); autoGroup.addActionListener(this); floatCb.addActionListener(this); highlCb.addActionListener(this); select.addActionListener(this); hideNonHits.addActionListener(this); grayOut.addActionListener(this); newButton.setToolTipText(Localization.lang("New group")); refresh.setToolTipText(Localization.lang("Refresh view")); andCb.setToolTipText(Localization.lang("Display only entries belonging to all selected groups.")); orCb.setToolTipText( Localization.lang("Display all entries belonging to one or more of the selected groups.")); autoGroup.setToolTipText(Localization.lang("Automatically create groups for database.")); invCb.setToolTipText(Localization.lang("Show entries *not* in group selection")); showOverlappingGroups.setToolTipText(Localization .lang("Highlight groups that contain entries contained in any currently selected group")); floatCb.setToolTipText(Localization.lang("Move entries in group selection to the top")); highlCb.setToolTipText(Localization.lang("Gray out entries not in group selection")); select.setToolTipText(Localization.lang("Select entries in group selection")); expand.setToolTipText(Localization.lang("Show one more row")); reduce.setToolTipText(Localization.lang("Show one less rows")); editModeCb.setToolTipText(Localization.lang("Click group to toggle membership of selected entries")); ButtonGroup bgr = new ButtonGroup(); bgr.add(andCb); bgr.add(orCb); ButtonGroup visMode = new ButtonGroup(); visMode.add(floatCb); visMode.add(highlCb); JPanel main = new JPanel(); GridBagLayout gbl = new GridBagLayout(); main.setLayout(gbl); GridBagConstraints con = new GridBagConstraints(); con.fill = GridBagConstraints.BOTH; //con.insets = new Insets(0, 0, 2, 0); con.weightx = 1; con.gridwidth = 1; con.gridx = 0; con.gridy = 0; //con.insets = new Insets(1, 1, 1, 1); gbl.setConstraints(newButton, con); main.add(newButton); con.gridx = 1; gbl.setConstraints(refresh, con); main.add(refresh); con.gridx = 2; gbl.setConstraints(autoGroup, con); main.add(autoGroup); con.gridx = 3; con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(helpButton, con); main.add(helpButton); // header.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); // helpButton.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); groupsTree = new GroupsTree(this); groupsTree.addTreeSelectionListener(this); groupsTree.setModel(groupsTreeModel = new DefaultTreeModel(groupsRoot)); JScrollPane sp = new JScrollPane(groupsTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); revalidateGroups(); con.gridwidth = GridBagConstraints.REMAINDER; con.weighty = 1; con.gridx = 0; con.gridwidth = 4; con.gridy = 1; gbl.setConstraints(sp, con); main.add(sp); JPanel pan = new JPanel(); GridBagLayout gb = new GridBagLayout(); con.weighty = 0; gbl.setConstraints(pan, con); pan.setLayout(gb); con.insets = new Insets(0, 0, 0, 0); con.gridx = 0; con.gridy = 0; con.weightx = 1; con.gridwidth = 4; con.fill = GridBagConstraints.HORIZONTAL; gb.setConstraints(openset, con); pan.add(openset); con.gridwidth = 1; con.gridx = 4; con.gridy = 0; gb.setConstraints(expand, con); pan.add(expand); con.gridx = 5; gb.setConstraints(reduce, con); pan.add(reduce); con.gridwidth = 6; con.gridy = 1; con.gridx = 0; con.fill = GridBagConstraints.HORIZONTAL; con.gridy = 2; con.gridx = 0; con.gridwidth = 4; gbl.setConstraints(pan, con); main.add(pan); main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); add(main, BorderLayout.CENTER); updateBorder(editModeIndicator); definePopup(); NodeAction moveNodeUpAction = new MoveNodeUpAction(); moveNodeUpAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK)); NodeAction moveNodeDownAction = new MoveNodeDownAction(); moveNodeDownAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK)); NodeAction moveNodeLeftAction = new MoveNodeLeftAction(); moveNodeLeftAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_MASK)); NodeAction moveNodeRightAction = new MoveNodeRightAction(); moveNodeRightAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_MASK)); }
From source file:me.solhub.simple.engine.DebugLocationsStructure.java
/** * Switches the color of the agent from destination to group or vice versa * whenever the space bar is pressed/* w ww . j a v a 2 s . c om*/ */ private void handleColorSwitchingInput() { if (_input.isKeyDown(KeyEvent.VK_SPACE) && inputDelayCount > inputDelay) { isDestinationColors = !isDestinationColors; inputDelayCount = 0; } if (_input.isKeyDown(KeyEvent.VK_PERIOD)) { LIVE_DELAY += 1; if (LIVE_DELAY < 0) { LIVE_DELAY = 0; } } if (_input.isKeyDown(KeyEvent.VK_COMMA)) { LIVE_DELAY -= 1; if (LIVE_DELAY < 0) { LIVE_DELAY = 0; } } if (_input.isKeyDown(KeyEvent.VK_UP)) { _yOffset += 1; } if (_input.isKeyDown(KeyEvent.VK_DOWN)) { _yOffset -= 1; } if (_input.isKeyDown(KeyEvent.VK_RIGHT)) { _xOffset -= 1; } if (_input.isKeyDown(KeyEvent.VK_LEFT)) { _xOffset += 1; } if (_input.isKeyDown(KeyEvent.VK_ENTER)) { while (!_input.isKeyDown(KeyEvent.VK_SHIFT)) { //this makes it work, without this line it will not work as desired // System.out.println(_input.isKeyDown( KeyEvent.VK_ENTER )); draw(); handleColorSwitchingInput(); } } inputDelayCount++; }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * When CTRL+Z is pressed invokes the <code>ChatWritePanel.undo()</code> * method, when CTRL+R is pressed invokes the * <code>ChatWritePanel.redo()</code> method. * * @param e the <tt>KeyEvent</tt> that notified us *//*from ww w . j av a 2 s. co m*/ public void keyPressed(KeyEvent e) { if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK && (e.getKeyCode() == KeyEvent.VK_Z) // And not ALT(right ALT gives CTRL + ALT). && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) { if (undo.canUndo()) undo(); } else if ((e.getModifiers() & KeyEvent.CTRL_MASK) == KeyEvent.CTRL_MASK && (e.getKeyCode() == KeyEvent.VK_R) // And not ALT(right ALT gives CTRL + ALT). && (e.getModifiers() & KeyEvent.ALT_MASK) != KeyEvent.ALT_MASK) { if (undo.canRedo()) redo(); } else if (e.getKeyCode() == KeyEvent.VK_TAB) { if (!(chatPanel.getChatSession() instanceof ConferenceChatSession)) return; e.consume(); int index = ((JEditorPane) e.getSource()).getCaretPosition(); StringBuffer message = new StringBuffer(chatPanel.getMessage()); int position = index - 1; while (position > 0 && (message.charAt(position) != ' ')) { position--; } if (position != 0) position++; String sequence = message.substring(position, index); if (sequence.length() <= 0) { // Do not look for matching contacts if the matching pattern is // 0 chars long, since all contacts will match. return; } Iterator<ChatContact<?>> iter = chatPanel.getChatSession().getParticipants(); ArrayList<String> contacts = new ArrayList<String>(); while (iter.hasNext()) { ChatContact<?> c = iter.next(); if (c.getName().length() >= (index - position) && c.getName().substring(0, index - position).equals(sequence)) { message.replace(position, index, c.getName().substring(0, index - position)); contacts.add(c.getName()); } } if (contacts.size() > 1) { char key = contacts.get(0).charAt(index - position - 1); int pos = index - position - 1; boolean flag = true; while (flag) { try { for (String name : contacts) { if (key != name.charAt(pos)) { flag = false; } } if (flag) { pos++; key = contacts.get(0).charAt(pos); } } catch (IndexOutOfBoundsException exp) { flag = false; } } message.replace(position, index, contacts.get(0).substring(0, pos)); Iterator<String> contactIter = contacts.iterator(); String contactList = "<DIV align='left'><h5>"; while (contactIter.hasNext()) { contactList += contactIter.next() + " "; } contactList += "</h5></DIV>"; chatPanel.getChatConversationPanel().appendMessageToEnd(contactList, ChatHtmlUtils.HTML_CONTENT_TYPE); } else if (contacts.size() == 1) { String limiter = (position == 0) ? ": " : ""; message.replace(position, index, contacts.get(0) + limiter); } try { ((JEditorPane) e.getSource()).getDocument().remove(0, ((JEditorPane) e.getSource()).getDocument().getLength()); ((JEditorPane) e.getSource()).getDocument().insertString(0, message.toString(), null); } catch (BadLocationException ex) { ex.printStackTrace(); } } else if (e.getKeyCode() == KeyEvent.VK_UP) { // Only enters editing mode if the write panel is empty in // order not to lose the current message contents, if any. if (this.chatPanel.getLastSentMessageUID() != null && this.chatPanel.isWriteAreaEmpty()) { this.chatPanel.startLastMessageCorrection(); e.consume(); } } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { if (chatPanel.isMessageCorrectionActive()) { Document doc = editorPane.getDocument(); if (editorPane.getCaretPosition() == doc.getLength()) { chatPanel.stopMessageCorrection(); } } } }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private void initGui(final String initialPath) { this.setLayout(new BorderLayout()); JLabel pathLabel = new JLabel(Messages.getMessage("browser.location")); pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); pathField = new JTextField(80); pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f)); pathField.setToolTipText(Messages.getMessage("nav.pathTooltip")); GuiUtils.addBlinkOnFocusGain(pathField); pathLabel.setLabelFor(pathField);//w w w. j a v a 2s .com pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0)); InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED); inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH"); inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) { @Override protected void performLongOperation(CheckBeforeActionResult actionResult) { try { FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim()); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); actionApproveDelegate.actionPerformed( // TODO: Does actionResult provide an ID for 2nd param here, // or should use a Random number? new ActionEvent(actionResult, (int) new java.util.Date().getTime(), "SELECTED_FILE")); return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(pathField.getText().trim()); } @Override protected boolean canGoUrl() { return true; } @Override protected boolean canExecuteDefaultAction() { return false; } }); actionFocusOnTable = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { tableFiles.requestFocusInWindow(); if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) { tableFiles.getSelectionModel().setSelectionInterval(0, 0); } } }; pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this); goUpButton = new JButton(goUpAction); BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this); JButton refreshButton = new JButton(refreshAction); JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName")); upperPanel.setRollover(true); upperPanel.add(pathLabel); upperPanel.add(pathField, "growx"); upperPanel.add(goUpButton); upperPanel.add(refreshButton); AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction( this); JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction); addCurrentLocationToFavoriteButton.setText(""); upperPanel.add(addCurrentLocationToFavoriteButton); previewComponent = new PreviewComponent(); vfsTableModel = new VfsTableModel(); tableFiles = new JTable(vfsTableModel); tableFiles.setFillsViewportHeight(true); tableFiles.getColumnModel().getColumn(0).setMinWidth(140); tableFiles.getColumnModel().getColumn(1).setMaxWidth(80); tableFiles.getColumnModel().getColumn(2).setMaxWidth(80); tableFiles.getColumnModel().getColumn(3).setMaxWidth(180); tableFiles.getColumnModel().getColumn(3).setMinWidth(120); sorter = new TableRowSorter<VfsTableModel>(vfsTableModel); final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator(); sorter.addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { RowSorterEvent.Type type = e.getType(); if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) { List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys(); for (RowSorter.SortKey sortKey : sortKeys) { if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) { fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder()); } } } } }); sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator); tableFiles.setRowSorter(sorter); tableFiles.setShowGrid(false); tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { try { selectionChanged(); } catch (FileSystemException e1) { LOGGER.error("Error during update state", e); } } }); tableFiles.setColumnSelectionAllowed(false); vfsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateStatusText(); } }); tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer()); tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer()); tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer()); tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer()); tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent)); JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]")); favoritesUserListModel = new MutableListModel<Favorite>(); List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations(); List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration); List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks(); for (Favorite favorite : favUser) { favoritesUserListModel.add(favorite); } favoritesUserListModel.addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { saveFavorites(); } @Override public void intervalRemoved(ListDataEvent e) { saveFavorites(); } @Override public void contentsChanged(ListDataEvent e) { saveFavorites(); } protected void saveFavorites() { FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList()); } }); favoritesUserList = new JList(favoritesUserListModel); favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList)); new MutableListDragListener(favoritesUserList); favoritesUserList.setCellRenderer(new FavoriteListCellRenderer()); favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter()); addOpenActionToList(favoritesUserList); addEditActionToList(favoritesUserList, favoritesUserListModel); favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction( Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) { @Override public void actionPerformed(ActionEvent e) { Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex()); if (!Favorite.Type.USER.equals(favorite.getType())) { return; } int response = JOptionPane.showConfirmDialog(VfsBrowser.this, Messages.getMessage("favorites.areYouSureToDeleteConnections"), Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { favoritesUserListModel.remove(favoritesUserList.getSelectedIndex()); } } }); InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED); favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE); ActionMap actionMap = tableFiles.getActionMap(); actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this)); actionMap.put(ACTION_GO_UP, goUpAction); actionMap.put(ACTION_APPROVE, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (actionApproveButton.isEnabled()) { actionApproveDelegate.actionPerformed(e); } } }); InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE); inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP); addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE); JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations)); favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer()); addOpenActionToList(favoriteSystemList); addPopupMenu(favoriteSystemList, ACTION_OPEN); favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter()); JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser)); addOpenActionToList(favoriteJVfsList); favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer()); addPopupMenu(favoriteJVfsList, ACTION_OPEN); favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter()); JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"), COMPUTER_ICON); favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList); favoritesSystemLocationsLabel .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0)); favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16"); favoritesPanel.add(favoriteSystemList, "growx"); JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"), Icons.getInstance().getStar()); favoritesFavoritesLabel.setLabelFor(favoritesUserList); favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0)); favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16"); favoritesPanel.add(favoritesUserList, "growx"); if (favoriteJVfsList.getModel().getSize() > 0) { JLabel favoritesJVfsFileChooser = getTitleListLabel( Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null); favoritesJVfsFileChooser.setDisplayedMnemonic( Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0)); favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList); favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16"); favoritesPanel.add(favoriteJVfsList, "growx"); } tableFiles.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null); } } }); tableFiles.addKeyListener(new QuickSearchKeyAdapter()); cardLayout = new CardLayout(); tablePanel = new JPanel(cardLayout); loadingProgressBar = new JProgressBar(); loadingProgressBar.setStringPainted(true); loadingProgressBar.setString(Messages.getMessage("browser.loading")); loadingProgressBar.setIndeterminate(true); loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline()); skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks")); skipCheckingLinksButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (taskContext != null) { taskContext.setStop(skipCheckingLinksButton.isSelected()); } } }); showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden); showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip")); showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0)); Font tmpFont = showHidCheckBox.getFont(); showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f)); showHidCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUiFilters(); } }); final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText"); filterField = new JTextField("", 16); filterField.setForeground(filterField.getDisabledTextColor()); filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip")); PromptSupport.setPrompt(defaultFilterText, filterField); filterField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { documentChanged(); } void documentChanged() { if (filterField.getText().length() == 0) { updateUiFilters(); } } @Override public void removeUpdate(DocumentEvent e) { documentChanged(); } @Override public void changedUpdate(DocumentEvent e) { documentChanged(); } }); filterField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { updateUiFilters(); } }); AbstractAction actionClearRegexFilter = new AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) { @Override public void actionPerformed(ActionEvent e) { filterField.setText(""); } }; filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_CLEAR_REGEX_FILTER); JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter")); nameFilterLabel.setLabelFor(filterField); nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0)); sorter.setRowFilter(createFilter()); statusLabel = new JLabel(); actionApproveButton = new JButton(); actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD)); actionCancelButton = new JButton(); ActionMap browserActionMap = this.getActionMap(); browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { filterField.requestFocus(); filterField.selectAll(); GuiUtils.blinkComponent(filterField); } }); browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField)); browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox)); browserActionMap.put(ACTION_REFRESH, refreshAction); browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction); browserActionMap.put(ACTION_GO_UP, goUpAction); browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles)); InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER); browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN); browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES); browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP); browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE); //DO layout // create the layer for the panel using our custom layerUI tableScrollPane = new JScrollPane(tableFiles); JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout()); tableScrollPaneWithFilter.add(tableScrollPane); JToolBar filtersToolbar = new JToolBar("Filters"); filtersToolbar.setFloatable(false); filtersToolbar.setBorderPainted(true); tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH); filtersToolbar.add(nameFilterLabel); filtersToolbar.add(filterField); filtersToolbar.add(showHidCheckBox); JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, tableScrollPaneWithFilter, previewComponent); tableWithPreviewPane.setOneTouchExpandable(true); JPanel loadingPanel = new JPanel(new MigLayout()); loadingPanel.add(loadingIconLabel, "right"); loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap"); loadingPanel.add(skipCheckingLinksButton, "span, right"); tablePanel.add(loadingPanel, LOADING); tablePanel.add(tableWithPreviewPane, TABLE); JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel), tablePanel); jSplitPane.setOneTouchExpandable(true); jSplitPane.setDividerLocation(180); JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", "")); southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); southPanel.add(statusLabel); southPanel.add(actionApproveButton); southPanel.add(actionCancelButton); this.add(upperPanel, BorderLayout.NORTH); this.add(jSplitPane, BorderLayout.CENTER); this.add(southPanel, BorderLayout.SOUTH); try { selectionChanged(); } catch (FileSystemException e) { LOGGER.error("Can't initialize default selection mode", e); } // Why this not done in EDT? // Is it assume that constructor is invoked from an EDT? try { if (initialPath == null) { goToUrl(VFSUtils.getUserHome()); } else { try { FileObject resolveFile = VFSUtils.resolveFileObject(initialPath); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); targetFileSelected = true; return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(initialPath); } } catch (FileSystemException e1) { LOGGER.error("Can't initialize default location", e1); } showTable(); }
From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java
private void initKeyListener() { //key listener thumbnailList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_UP)) { moveUpButton.doClick();/*from w w w .j a v a 2 s . c o m*/ } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_DOWN)) { moveDownButton.doClick(); } else if ((e.getKeyCode() == KeyEvent.VK_DELETE)) { removeButton.doClick(); } else if (drawDeletedItems && (e.isControlDown()) && (e.getKeyCode() == KeyEvent.VK_Z)) { undeleteButton.doClick(); } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_RIGHT)) { rotateButton.doClick(); } else if ((e.isAltDown()) && (e.getKeyCode() == KeyEvent.VK_LEFT)) { rotateAntiButton.doClick(); } } }); }
From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DHeatmapViewerPanel.java
@Override public void keyPressed(KeyEvent ke) { Logger.getLogger(getClass().getName()).log(Level.INFO, "Received key event: {0}", ke.toString()); if (ke.isControlDown()) { modeSpinner.setValue(InstanceContentSelectionHandler.Mode.ON_HOVER.toString()); }/*from w w w. j av a 2 s . co m*/ if (getDataPoint() != null) { Logger.getLogger(getClass().getName()).info("Data point is not null!"); Point p = null; if (ke.getKeyCode() == KeyEvent.VK_RIGHT) { p = new Point(getDataPoint()); p.translate(1, 0); } else if (ke.getKeyCode() == KeyEvent.VK_LEFT) { p = new Point(getDataPoint()); p.translate(-1, 0); } else if (ke.getKeyCode() == KeyEvent.VK_UP) { p = new Point(getDataPoint()); p.translate(0, 1); } else if (ke.getKeyCode() == KeyEvent.VK_DOWN) { p = new Point(getDataPoint()); p.translate(0, -1); } setDataPoint(p); if (!ke.isShiftDown()) { // triggerMSUpdate(); } } }
From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java
/** * Creates new form JTicketView/*from w w w . j a v a2 s . c o m*/ */ public JRetailPanelTakeAway() { initComponents(); tnbbutton = new ThumbNailBuilderPopularItems(110, 57, "com/openbravo/images/bluetoit.png"); TextListener txtL; // cusName = (JTextField) m_jCboCustName.getEditor().getEditorComponent(); // cusPhoneNo= (JTextField) m_jCboContactNo.getEditor().getEditorComponent(); itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent(); m_jTxtItemCode.setFocusable(true); // m_jTxtCustomerId.setFocusable(true); txtL = new TextListener(); // m_jCreditAllowed.setVisible(false); // m_jCreditAllowed.setSelected(false); // cusPhoneNo.addFocusListener(txtL); //cusName.addFocusListener(txtL); itemName.addFocusListener(txtL); Action doMorething = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jPrice.setEnabled(true); // m_jPrice.setFocusable(true); m_jKeyFactory.setFocusable(true); m_jKeyFactory.setText(null); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { m_jKeyFactory.requestFocus(); } }); } }; // InputMap imap = m_jPrice.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK), "doMorething"); // m_jPrice.getActionMap().put("doMorething",doMorething); // Action doLastBill = new AbstractAction() { // public void actionPerformed(ActionEvent e) { // m_jLastBillActionPerformed(e); // stateToZero(); // } // }; // InputMap imapLastBill = m_jLastBill.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imapLastBill.put(KeyStroke.getKeyStroke("F7"), "doLastBill"); // m_jLastBill.getActionMap().put("doLastBill",doLastBill); Action cashNoBill = new AbstractAction() { public void actionPerformed(ActionEvent e) { // cashPayment(3); // setPrinterOn(); } }; InputMap imapCashNoBill = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCashNoBill.put(KeyStroke.getKeyStroke("F1"), "cashNoBill"); m_jAction.getActionMap().put("cashNoBill", cashNoBill); // }; Action cashReceipt = new AbstractAction() { public void actionPerformed(ActionEvent e) { // cashPayment(2); } }; InputMap imapCashReceipt = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCashReceipt.put(KeyStroke.getKeyStroke("F2"), "cashReceipt"); m_jAction.getActionMap().put("cashReceipt", cashReceipt); Action docashPrint = new AbstractAction() { public void actionPerformed(ActionEvent e) { // cashPayment(1); } }; InputMap imapCashPrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCashPrint.put(KeyStroke.getKeyStroke("F3"), "docashPrint"); m_jAction.getActionMap().put("docashPrint", docashPrint); Action doCardnobill = new AbstractAction() { public void actionPerformed(ActionEvent e) { //m_jCloseShiftActionPerformed(e); // cardPayment(1); } }; InputMap imapCardnoBill = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCardnoBill.put(KeyStroke.getKeyStroke("F4"), "doCardnobill"); m_jAction.getActionMap().put("doCardnobill", doCardnobill); Action doNonChargablePrint = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { closeTicketNonChargable(m_oTicket, m_oTicketExt, m_aPaymentInfo); } catch (BasicException ex) { logger.info("exception in closeTicketNonChargable" + ex.getMessage()); Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } } }; InputMap imapNonChargablePrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapNonChargablePrint.put(KeyStroke.getKeyStroke("F7"), "doNonChargablePrint"); m_jAction.getActionMap().put("doNonChargablePrint", doNonChargablePrint); Action doCreditreceipt = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jCreditAmount.setText(Double.toString(m_oTicket.getTotal())); // // try { // closeCreditTicket(m_oTicket, m_oTicketExt, m_aPaymentInfo); // } catch (BasicException ex) { // Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); // } } }; InputMap imapCreditReceipt = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCreditReceipt.put(KeyStroke.getKeyStroke("F5"), "doCreditreceipt"); m_jAction.getActionMap().put("doCreditreceipt", doCreditreceipt); Action doHomeDeliveryNotPaid = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jHomeDelivery.setSelected(true); if (getEditSale() == "Edit") { // getServiceCharge("Y"); printPartialTotals(); try { closeTicketHomeDelivery(m_oTicket, m_oTicketExt, m_aPaymentInfo); } catch (BasicException ex) { logger.info("exception in closeTicketHomeDelivery" + ex.getMessage()); Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } } } }; InputMap imapCardPrint = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapCardPrint.put(KeyStroke.getKeyStroke("F6"), "doHomeDeliveryNotPaid"); m_jAction.getActionMap().put("doHomeDeliveryNotPaid", doHomeDeliveryNotPaid); Action doLogout = new AbstractAction() { public void actionPerformed(ActionEvent e) { m_jLogoutActionPerformed(e); } }; InputMap imapLog = m_jLogout.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapLog.put(KeyStroke.getKeyStroke("F12"), "doLogout"); m_jLogout.getActionMap().put("doLogout", doLogout); Action doupArrow = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jUpActionPerformed(e); } }; InputMap imapUpArrow = m_jPlus.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapUpArrow.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "doupArrow"); m_jPlus.getActionMap().put("doupArrow", doupArrow); // Action doCustomer = new AbstractAction() { // public void actionPerformed(ActionEvent e) { // //// m_jTxtCustomerId.setFocusable(true); // // // cusPhoneNo.setFocusable(true); // // cusName.setFocusable(true); // stateToBarcode(); // } // }; // InputMap imapCustomer= m_jTxtCustomerId.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imapCustomer.put(KeyStroke.getKeyStroke("F8"), "doCustomer"); // m_jTxtCustomerId.getActionMap().put("doCustomer", // doCustomer); Action doItem = new AbstractAction() { public void actionPerformed(ActionEvent e) { itemName.setFocusable(true); m_jTxtItemCode.setFocusable(true); stateToItem(); } }; InputMap imapItem = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapItem.put(KeyStroke.getKeyStroke("F9"), "doItem"); m_jAction.getActionMap().put("doItem", doItem); // Action doHomeDelivery = new AbstractAction() { // public void actionPerformed(ActionEvent e) { //// m_jHomeDelivery.setFocusable(true); // // m_jHomeDelivery.setSelected(true); // // m_jHomeDeliveryActionPerformed(e); // // m_jTxtAdvance.setFocusable(true); // stateToHomeDelivery(); // } // }; // // InputMap imapHomeDelivery= m_jHomeDelivery.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); // imapHomeDelivery.put(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.ALT_MASK), "doHomeDelivery"); // m_jHomeDelivery.getActionMap().put("doHomeDelivery", // doHomeDelivery); // Action doPayment = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jCash.setFocusable(true); // m_jCard.setFocusable(true); // m_jCheque.setFocusable(true); // m_jtxtChequeNo.setFocusable(true); // m_jFoodCoupon.setFocusable(true); // m_jVoucher.setFocusable(true); // m_jCreditAmount.setFocusable(true); stateToPayment(); } }; InputMap imapPayment = m_jAction.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapPayment.put(KeyStroke.getKeyStroke("F11"), "doPayment"); m_jAction.getActionMap().put("doPayment", doPayment); Action doDownpArrow = new AbstractAction() { public void actionPerformed(ActionEvent e) { // m_jDownActionPerformed(e); } }; InputMap imapArrow = m_jMinus.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imapArrow.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "doDownpArrow"); m_jMinus.getActionMap().put("doDownpArrow", doDownpArrow); itemName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!itemName.getText().equals("") || !itemName.getText().equals(null)) { incProductByItemDetails(pdtId); // itemName.setText(""); // m_jCboItemName.setSelectedIndex(-1); ArrayList<String> itemCode = new ArrayList<String>(); ArrayList<String> itemName1 = new ArrayList<String>(); vItemName.removeAllElements(); try { productListDetails = (ArrayList<ProductInfoExt>) dlSales.getProductDetails(); } catch (BasicException ex) { Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } for (ProductInfoExt product : productListDetails) { itemCode.add(product.getItemCode()); itemName1.add(product.getName()); } String[] productName = itemName1.toArray(new String[itemName1.size()]); for (int i = 0; i < itemName1.size(); i++) { vItemName.addElement(productName[i]); } itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent(); } else { pdtId = ""; ArrayList<String> itemCode = new ArrayList<String>(); ArrayList<String> itemName1 = new ArrayList<String>(); vItemName.removeAllElements(); try { productListDetails = (ArrayList<ProductInfoExt>) dlSales.getProductDetails(); } catch (BasicException ex) { Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex); } for (ProductInfoExt product : productListDetails) { itemCode.add(product.getItemCode()); itemName1.add(product.getName()); } String[] productName = itemName1.toArray(new String[itemName1.size()]); for (int i = 0; i < itemName1.size(); i++) { vItemName.addElement(productName[i]); } itemName = (JTextField) m_jCboItemName.getEditor().getEditorComponent(); } } }); }
From source file:com.jvms.i18neditor.editor.Editor.java
private void setupGlobalKeyEventDispatcher() { KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(e -> { if (e.getID() != KeyEvent.KEY_PRESSED || !e.isAltDown() || (SystemUtils.IS_OS_MAC && !e.isMetaDown()) || (!SystemUtils.IS_OS_MAC && !e.isShiftDown())) { return false; }//from ww w .j a va2s . co m TreePath selected = translationTree.getSelectionPath(); if (selected == null) { return false; } boolean result = false; int row = translationTree.getRowForPath(selected); switch (e.getKeyCode()) { case KeyEvent.VK_RIGHT: if (!translationTree.isExpanded(row)) { translationTree.expandRow(row); } result = true; break; case KeyEvent.VK_LEFT: if (translationTree.isCollapsed(row)) { translationTree.setSelectionPath(selected.getParentPath()); } else { translationTree.collapseRow(row); } result = true; break; case KeyEvent.VK_UP: TreePath prev = translationTree.getPathForRow(Math.max(0, row - 1)); if (prev != null) { translationTree.setSelectionPath(prev); } result = true; break; case KeyEvent.VK_DOWN: TreePath next = translationTree.getPathForRow(row + 1); if (next != null) { translationTree.setSelectionPath(next); } result = true; break; } if (result && !resourceFields.isEmpty()) { Component comp = getFocusOwner(); if (comp != null && (comp instanceof ResourceField || comp.equals(this))) { TranslationTreeNode current = translationTree.getSelectionNode(); if (!current.isLeaf() || current.isRoot()) { requestFocusInWindow(); } else if (comp.equals(this)) { requestFocusInFirstResourceField(); } } } return result; }); }
From source file:schemagenerator.DBbeheer.java
private void Table_OefeningenKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_Table_OefeningenKeyReleased if (evt.getKeyCode() == KeyEvent.VK_DOWN || evt.getKeyCode() == KeyEvent.VK_UP) { try {//from ww w . ja va2 s . c om int row = Table_Oefeningen.getSelectedRow(); String tableClick = (Table_Oefeningen.getModel().getValueAt(row, 0).toString()); String sql = "SELECT * FROM oefeningen WHERE spiergroep='" + tableClick + "'"; pst = con.prepareStatement(sql); rs = pst.executeQuery(); if (rs.next()) { String add1 = rs.getString("ID"); jtfID.setText(add1); String add2 = rs.getString("spiergroep"); jtfSpiergroep.setText(add2); String add3 = rs.getString("oefening"); jtfOefening.setText(add3); String add4 = rs.getString("categorie"); jtfCategorie.setText(add4); byte[] imagedata = rs.getBytes("plaatje"); format = new ImageIcon(imagedata); jlPlaatje.setIcon(format); } } catch (Exception ex) { try { int row = Table_Oefeningen.getSelectedRow(); String tableClick = (Table_Oefeningen.getModel().getValueAt(row, 0).toString()); String sql = "SELECT * FROM oefeningen WHERE spiergroep='" + tableClick + "'"; pst = con.prepareStatement(sql); rs = pst.executeQuery(); if (rs.next()) { String add1 = rs.getString("ID"); jtfID.setText(add1); String add2 = rs.getString("spiergroep"); jtfSpiergroep.setText(add2); String add3 = rs.getString("oefening"); jtfOefening.setText(add3); String add4 = rs.getString("categorie"); jtfCategorie.setText(add4); jlPlaatje.setIcon(null); } } catch (Exception ex1) { JOptionPane.showMessageDialog(null, ex1); } } } }