public void loadBindingMap(InputMap im, ActionMap am) { results.append("Bound Actions\n"); String unboundActions = ""; String unboundInputKeys = ""; Hashtable mi = buildReverseMap(im); Object[] k = am.allKeys(); if (k != null) { for (int i = 0; i < k.length; i++) { if (mi.containsKey(k[i])) { results.append(" " + getActionName(k[i])); results.append(";" + mi.get(k[i]) + "\n"); } else { unboundActions += (" " + getActionName(k[i]) + "\n"); } } results.append("\nUnbound Actions\n\n"); results.append(unboundActions); } results.append("\nUnbound InputMap Entries\n"); k = im.allKeys(); if (k != null) { for (int i = 0; i < k.length; i++) { KeyStroke key = (KeyStroke) k[i]; Object actionKey = im.get(key); if (am.get(actionKey) == null) { results.append(" " + im.get((KeyStroke) k[i]) + ": " + k[i] + "\n"); } } } }
private void tastenbelegen() { javax.swing.ActionMap am = getRootPane().getActionMap(); javax.swing.InputMap im = getRootPane().getInputMap(javax.swing.JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); // ESC - Taste Object EscapeObjekt = new Object(); javax.swing.KeyStroke EscapeStroke = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0); javax.swing.Action EscapeAction = new javax.swing.AbstractAction() { public void actionPerformed(java.awt.event.ActionEvent evt) { antwort = false; // Befehl setVisible(false); } }; im.put(EscapeStroke, EscapeObjekt); am.put(EscapeObjekt, EscapeAction); // ENTER - Taste Object EnterObjekt = new Object(); javax.swing.KeyStroke EnterStroke = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0); javax.swing.Action EnterAction = new javax.swing.AbstractAction() { public void actionPerformed(java.awt.event.ActionEvent evt) { antwort = true; // Befehl setVisible(false); } }; im.put(EnterStroke, EnterObjekt); am.put(EnterObjekt, EnterAction); }
private static void fixKeyStroke(JTextField textField, String name, int vk, int mask) { Action action = null; ActionMap actionMap = textField.getActionMap(); for (Object k : actionMap.allKeys()) { if (k.equals(name)) { action = actionMap.get(k); } } if (action != null) { InputMap[] inputMaps = new InputMap[] { textField.getInputMap(JComponent.WHEN_FOCUSED), textField.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT), textField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) }; for (InputMap i : inputMaps) { i.put( KeyStroke.getKeyStroke(vk, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | mask), action); } } }
private void init() { final JPanel contentPanel = new JPanel(new BorderLayout()); contentPanel.add(createContent(), BorderLayout.CENTER); contentPanel.setBorder(Borders.DIALOG_BORDER); final JPanel panel = new JPanel(new BorderLayout()); panel.add(createHeaderPanel(), BorderLayout.NORTH); panel.add(contentPanel, BorderLayout.CENTER); panel.add(createButtons(), BorderLayout.SOUTH); // register the "escape" key to "cancel" the dialog final String cancelActionCommand = "_cancel"; final InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelActionCommand); final ActionMap actionMap = getRootPane().getActionMap(); actionMap.put( cancelActionCommand, new AbstractAction() { public void actionPerformed(ActionEvent e) { onCancel(); } }); setContentPane(panel); super.pack(); setLocationRelativeTo(getOwner()); initDone = true; }
public ExtendedTriStateCheckBox(String text, Icon icon, Boolean initial) { super(text, icon); // Add a listener for when the mouse is pressed super.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabFocus(); model.nextState(); } }); // Reset the keyboard action map ActionMap map = new ActionMapUIResource(); map.put( "pressed", new AbstractAction() { // NOI18N private static final long serialVersionUID = 0L; @Override public void actionPerformed(ActionEvent e) { grabFocus(); model.nextState(); } }); map.put("released", null); // NOI18N SwingUtilities.replaceUIActionMap(this, map); // set the model to the adapted model model = new TristateDecorator(getModel()); setModel(model); setState(initial); }
private void AboutBoxKeyEventActionIntialization() { Action ESCactionListener = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { setVisible(false); dispose(); } }; KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true); JComponent comp = this.getRootPane(); comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ESCAPE"); ActionMap actionMap = comp.getActionMap(); actionMap.put("ESCAPE", ESCactionListener); /* OK button Action Solves MAC , Linux and Window enter key issue*/ Action OKactionListener = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { btnOKActionPerformed(actionEvent); } }; KeyStroke enter_ok = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true); btnOK.getInputMap(JButton.WHEN_FOCUSED).put(enter_ok, "OK"); actionMap = btnOK.getActionMap(); actionMap.put("OK", OKactionListener); btnOK.setActionMap(actionMap); }
/** * Constructs a new {@code QuadStateCheckBox}. * * @param text the text of the check box * @param icon the Icon image to display * @param initial The initial state * @param allowed The allowed states */ public QuadStateCheckBox(String text, Icon icon, State initial, State[] allowed) { super(text, icon); this.allowed = Utils.copyArray(allowed); // Add a listener for when the mouse is pressed super.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabFocus(); model.nextState(); } }); // Reset the keyboard action map ActionMap map = new ActionMapUIResource(); map.put( "pressed", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { grabFocus(); model.nextState(); } }); map.put("released", null); SwingUtilities.replaceUIActionMap(this, map); // set the model to the adapted model model = new QuadStateDecorator(getModel()); setModel(model); setState(initial); }
// For testing only at present IndeterminateCheckBox( final String text, final Icon icon, final SelectionState initial, final boolean original) { super(text, icon); setBorderPaintedFlat(true); // Set default single model setModel(new ButtonModelEx(initial, this, original)); // override action behaviour super.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { IndeterminateCheckBox.this.iterateState(); } }); final ActionMap actions = new ActionMapUIResource(); actions.put( "pressed", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { IndeterminateCheckBox.this.iterateState(); } }); actions.put("released", null); SwingUtilities.replaceUIActionMap(this, actions); }
public static void hideOnEscape(Object ob) { if (ob instanceof JComponent) { final JComponent comp = (JComponent) ob; InputMap inputMap = comp.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = comp.getRootPane().getActionMap(); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), actionMap); actionMap.put( actionMap, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { comp.setVisible(false); } }); } else if (ob instanceof JDialog) { final JDialog dialog = (JDialog) ob; InputMap inputMap = dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = dialog.getRootPane().getActionMap(); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), actionMap); actionMap.put( actionMap, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); } }
@Override protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); // Hide Window on ESC Action escapeAction = new AbstractAction("ESCAPE") { // $NON-NLS-1$ /** */ private static final long serialVersionUID = -6543764044868772971L; @Override public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }; // Do search on Enter Action enterAction = new AbstractAction("ENTER") { // $NON-NLS-1$ private static final long serialVersionUID = -3661361497864527363L; @Override public void actionPerformed(final ActionEvent actionEvent) { checkDirtyAndLoad(actionEvent); } }; ActionMap actionMap = rootPane.getActionMap(); actionMap.put(escapeAction.getValue(Action.NAME), escapeAction); actionMap.put(enterAction.getValue(Action.NAME), enterAction); InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME)); inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME)); return rootPane; }
private JMenu createFileMenu() { ActionMap actionMap = context.getActionMap(this); final JMenu file = new JMenu("File"); file.setMnemonic('f'); file.add(actionMap.get("openProject")); final JMenu fileRecent = new JMenu("Recent Projects"); fileRecent.setIcon(new ImageIcon("/resources/icons/open.png")); fileRecent.addMenuListener(new RecentProjectsMenuManager(application, projectService)); file.add(fileRecent); file.addSeparator(); final JMenu fileExport = new JMenu("Export To"); fileExport.setIcon(new ImageIcon("/resources/icons/exportTo.png")); fileExport.add(application.getAction(ExportToHtml.COMMAND)); fileExport.add(application.getAction(ExportToRecordBundle.COMMAND)); file.add(fileExport); final JMenu fileImport = new JMenu("Import From"); fileExport.setIcon(new ImageIcon("/resources/icons/import.png")); fileImport.add(application.getAction(ImportFromRecordBundle.COMMAND)); file.add(fileImport); file.addSeparator(); file.add(application.getAction(NewRvConnection.COMMAND)); final JMenu connRecent = new JMenu("Recent Connections"); connRecent.addMenuListener(new RecentConnectionsMenuManager(application)); file.add(connRecent); return file; }
/* * Assign ENTER and ESCAPE keystrokes to be equivalent to OK and Cancel buttons, respectively. */ @SuppressWarnings("serial") protected void setupKeys() { // Get the InputMap and ActionMap of the RootPane of this JDialog. JRootPane rootPane = this.getRootPane(); InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = rootPane.getActionMap(); // Setup ENTER key. inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter"); actionMap.put( "enter", new AbstractAction() { public void actionPerformed(ActionEvent e) { okChosen(); } }); // Setup ESCAPE key. inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); actionMap.put( "escape", new AbstractAction() { public void actionPerformed(ActionEvent e) { cancelChosen(); } }); // Stop table_ from consuming the ENTER keystroke and preventing it from being received by this // (JDialog). table_ .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "none"); }
public SimpleSearchDialog(JDialog owner, SearchableListDialog dialogToSearch) { super(owner, false); _owner = owner; _dialogToSearch = dialogToSearch; _lastMatchedListIndex = -1; ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(SimpleSearchDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); setTitle(title); getContentPane().setLayout(new BorderLayout(0, 0)); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(10, 10, 10, 10)); getContentPane().add(_pnlMain, BorderLayout.NORTH); _pnlMain.setLayout(new BorderLayout(0, 0)); _lblEnterSearchString = new JLabel(enterStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 10, 0)); _pnlMain.add(_lblEnterSearchString, BorderLayout.NORTH); _txtFldSearch = new JTextField(); _pnlMain.add(_txtFldSearch); _txtFldSearch.setColumns(10); _pnlButtons = new JPanel(); getContentPane().add(_pnlButtons, BorderLayout.SOUTH); _btnSearch = new JButton(); _btnSearch.setAction(actionMap.get("SimpleSearchDialog_Search")); _pnlButtons.add(_btnSearch); _btnCancel = new JButton(); _btnCancel.setAction(actionMap.get("SimpleSearchDialog_Cancel")); _pnlButtons.add(_btnCancel); _txtFldSearch .getDocument() .addDocumentListener( new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { _lastMatchedListIndex = -1; } @Override public void insertUpdate(DocumentEvent e) { _lastMatchedListIndex = -1; } @Override public void changedUpdate(DocumentEvent e) { _lastMatchedListIndex = -1; } }); }
/** Creates new form ClienteUsuarioModifica */ public DlgClienteNuevo(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); InitDialogData(); setTitle(TDSLanguageUtils.getMessage("client.SS2.Client.NuevoDialog")); b_OK.setText(TDSLanguageUtils.getMessage("client.SS2.btnOK")); b_Cancel.setText(TDSLanguageUtils.getMessage("client.SS2.btnCancel")); l_numeroCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.numclient")); l_fechAltaCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.dataalta")); l_nifCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.nif")); l_nombreCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.nom")); l_apellidosCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.cognoms")); l_direccionCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.adreca")); l_poblacionCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.poblacio")); l_codigoPostalCliente.setText(TDSLanguageUtils.getMessage("client.SS2.Client.codipostal")); l_error.setText(""); JRootPane rootPanel = this.getRootPane(); InputMap iMap = rootPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); ActionMap aMap = rootPanel.getActionMap(); aMap.put( "escape", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); }; }); }
public QuadristateCheckbox(String text, Icon icon, State state) { super(text, icon); // Add a listener for when the mouse is pressed super.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { grabFocus(); getModel().nextState(); } }); // Reset the keyboard action map ActionMap map = new ActionMapUIResource(); map.put( "pressed", new AbstractAction() { public void actionPerformed(ActionEvent e) { grabFocus(); getModel().nextState(); } }); map.put("released", null); SwingUtilities.replaceUIActionMap(this, map); setState(state); }
public ActionFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); buttonPanel = new JPanel(); // define actions Action yellowAction = new ColorAction("Yellow", new ImagIcon("yellow-ball.gif"), Color.YELLOW); Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.BLUE); Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.RED); // add buttons for these actions buttonPanel.add(new JButton(yellowAction)); buttonPanel.add(new JButton(blueAction)); buttonPanel.add(new JButton(recAction)); // add panel to frame add(buttonPanel); // associate the Y, B, and R keys with names InputMap imap = buttonPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); imap.put(KeyStroke.getKeyStroke("ctrl Y"), "panel.yellow"); imap.put(KeyStroke.getKeyStroke("Ctrl B"), "panel.blue"); imap.put(KeyStroke.getKeyStroke("ctrl R"), "panel.red"); // associate the names with actions ActionMap amap = buttonPanel.getActionMap(); amap.put("panel.yellow", yellowAction); amap.put("panel.blue", blueAction); amap.put("panel.red", redAction); }
private void init(String title) { diag = new JDialog(frame, title, false); preview = new PreviewPanel(null, new MetaData(), Globals.prefs.get("preview1")); sortedEntries = new SortedList<BibtexEntry>(entries, new EntryComparator(false, true, "author")); model = new EventTableModel<BibtexEntry>(sortedEntries, new EntryTableFormat()); entryTable = new JTable(model); GeneralRenderer renderer = new GeneralRenderer(Color.white); entryTable.setDefaultRenderer(JLabel.class, renderer); entryTable.setDefaultRenderer(String.class, renderer); setWidths(); TableComparatorChooser<BibtexEntry> tableSorter = new TableComparatorChooser<BibtexEntry>( entryTable, sortedEntries, TableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); setupComparatorChooser(tableSorter); JScrollPane sp = new JScrollPane(entryTable); EventSelectionModel<BibtexEntry> selectionModel = new EventSelectionModel<BibtexEntry>(sortedEntries); entryTable.setSelectionModel(selectionModel); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); entryTable.addMouseListener(new TableClickListener()); contentPane.setTopComponent(sp); contentPane.setBottomComponent(preview); // Key bindings: AbstractAction closeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { diag.dispose(); } }; ActionMap am = contentPane.getActionMap(); InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.prefs.getKey("Close dialog"), "close"); am.put("close", closeAction); diag.addWindowListener( new WindowAdapter() { public void windowOpened(WindowEvent e) { contentPane.setDividerLocation(0.5f); } public void windowClosing(WindowEvent event) { Globals.prefs.putInt("searchDialogWidth", diag.getSize().width); Globals.prefs.putInt("searchDialogHeight", diag.getSize().height); } }); diag.getContentPane().add(contentPane, BorderLayout.CENTER); // Remember and default to last size: diag.setSize( new Dimension( Globals.prefs.getInt("searchDialogWidth"), Globals.prefs.getInt("searchDialogHeight"))); diag.setLocationRelativeTo(frame); }
public ActionMap getActionMap() { ActionMap map = createActionMap(); map.get(PREV).setEnabled(false); map.get(NEXT).putValue(Action.NAME, getString("reservation_wizard.appointment_menu")); map.get(NEXT).putValue(Action.SMALL_ICON, getIcon("icon.arrow_right")); map.get(FINISH).setEnabled(false); return map; }
/** * Bind a key to an action. The binding will be active while the Workspace window is selected. * * @param keyDescription A string describing the key as per KeyStroke.getKeyStroke(String). Ex: * "alt A" or "ctrl UP" (for up-arrow). Key names are the <keyName> part in VK_<keyName> * @param action Action object to invoke when key is pressed. */ public void bindKey(String keyDescription, Action action) { InputMap keyMap = _panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = _panel.getActionMap(); keyMap.put(KeyStroke.getKeyStroke(keyDescription), keyDescription); actionMap.put(keyDescription, action); }
public ActionMap createActionMap() { ActionMap map = new ActionMap(); map.put(WizardPanel.ABORT, new Handler(getString("abort"), getIcon("icon.abort"))); map.put(WizardPanel.PREV, new Handler(getString("back"), getIcon("icon.arrow_left"))); map.put(WizardPanel.NEXT, new Handler(null, null)); map.put(WizardPanel.FINISH, new Handler(getString("save"), getIcon("icon.save"))); return map; }
public static void sysoutActionMap(JComponent com) { final ActionMap am = com.getActionMap(); Object[] keys = am.allKeys(); for (Object ks : keys) { System.out.println(ks.toString() + " : " + am.get(ks)); } }
/** * Set up key bindings and focus listener for the FieldEditor. * * @param component */ public void setupJTextComponent(final JComponent component, final AutoCompleteListener acl) { // Here we add focus listeners to the component. The funny code is because we need // to guarantee that the AutoCompleteListener - if used - is called before fieldListener // on a focus lost event. The AutoCompleteListener is responsible for removing any // current suggestion when focus is lost, and this must be done before fieldListener // stores the current edit. Swing doesn't guarantee the order of execution of event // listeners, so we handle this by only adding the AutoCompleteListener and telling // it to call fieldListener afterwards. If no AutoCompleteListener is used, we // add the fieldListener normally. if (acl != null) { component.addKeyListener(acl); component.addFocusListener(acl); acl.setNextFocusListener(fieldListener); } else component.addFocusListener(fieldListener); InputMap im = component.getInputMap(JComponent.WHEN_FOCUSED); ActionMap am = component.getActionMap(); im.put(Globals.prefs.getKey("Entry editor, previous entry"), "prev"); am.put("prev", parent.prevEntryAction); im.put(Globals.prefs.getKey("Entry editor, next entry"), "next"); am.put("next", parent.nextEntryAction); im.put(Globals.prefs.getKey("Entry editor, store field"), "store"); am.put("store", parent.storeFieldAction); im.put(Globals.prefs.getKey("Entry editor, next panel"), "right"); im.put(Globals.prefs.getKey("Entry editor, next panel 2"), "right"); am.put("left", parent.switchLeftAction); im.put(Globals.prefs.getKey("Entry editor, previous panel"), "left"); im.put(Globals.prefs.getKey("Entry editor, previous panel 2"), "left"); am.put("right", parent.switchRightAction); im.put(Globals.prefs.getKey("Help"), "help"); am.put("help", parent.helpAction); im.put(Globals.prefs.getKey("Save database"), "save"); am.put("save", parent.saveDatabaseAction); im.put(Globals.prefs.getKey("Next tab"), "nexttab"); am.put("nexttab", parent.frame.nextTab); im.put(Globals.prefs.getKey("Previous tab"), "prevtab"); am.put("prevtab", parent.frame.prevTab); try { HashSet<AWTKeyStroke> keys = new HashSet<AWTKeyStroke>( component.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS)); keys.clear(); keys.add(AWTKeyStroke.getAWTKeyStroke("pressed TAB")); component.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keys); keys = new HashSet<AWTKeyStroke>( component.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS)); keys.clear(); keys.add(KeyStroke.getKeyStroke("shift pressed TAB")); component.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, keys); } catch (Throwable t) { System.err.println(t); } }
protected void addWidgets(DescriptorQueryList list, ActionMap actions, boolean captionsOnly) { setLayout(new BorderLayout()); setBorder(BorderFactory.createTitledBorder(caption)); setBackground(AmbitColors.BrightClr); setForeground(AmbitColors.DarkClr); tableModel = new DescriptorQueryTableModel(list, captionsOnly); JTable table = new JTable(tableModel, createTableColumnModel(tableModel, captionsOnly)); table.setSurrendersFocusOnKeystroke(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionAllowed(false); table.getTableHeader().setReorderingAllowed(false); table.setRowHeight(24); TableColumn col; int[] pSize = {32, 240, 32, 32, 64, 32, 32, 32}; int[] mSize = {24, 120, 32, 32, 64, 32, 32, 32}; for (int i = 0; i < table.getColumnCount(); i++) { col = table.getColumnModel().getColumn(i); col.setPreferredWidth(pSize[i]); col.setMinWidth(mSize[i]); } // table.setShowGrid(false); table.setShowHorizontalLines(true); table.setShowVerticalLines(false); scrollPane = new JScrollPane(table); scrollPane.setPreferredSize(new Dimension(420, 360)); scrollPane.setMinimumSize(new Dimension(370, 120)); scrollPane.setAutoscrolls(true); // tPane.addTab("Search descriptors",scrollPane); add(scrollPane, BorderLayout.CENTER); /* JToolBar t = new JToolBar(); //t.setBackground(Color.white); t.setFloatable(false); //t.setBorder(BorderFactory.createTitledBorder("Search by descriptors and distance between atoms")); Object[] keys = actions.allKeys(); if (keys != null) { for (int i=0; i < keys.length;i++) t.add(actions.get(keys[i])); add(t,BorderLayout.SOUTH); } */ if (actions != null) { Object[] keys = actions.allKeys(); if (keys != null) { for (int i = 0; i < keys.length; i++) { add( new DescriptorSearchActionPanel(list, actions.get(keys[i]), keys[i].toString()), BorderLayout.SOUTH); break; } } } }
public ActionMap getActionMap() { ActionMap map = createActionMap(); nextAction = map.get(NEXT); nextAction.putValue(Action.NAME, getString("reservation_wizard.add_appointment")); nextAction.putValue(Action.SMALL_ICON, getIcon("icon.new")); nextAction.setEnabled(false); map.get(FINISH).setEnabled(false); return map; }
/** * Print Action and Input Map for component * * @param comp Component with ActionMap */ public static void printActionInputMap(JComponent comp) { // Action Map ActionMap am = comp.getActionMap(); Object[] amKeys = am.allKeys(); // including Parents if (amKeys != null) { System.out.println("-------------------------"); System.out.println("ActionMap for Component " + comp.toString()); for (int i = 0; i < amKeys.length; i++) { Action a = am.get(amKeys[i]); StringBuffer sb = new StringBuffer("- "); sb.append(a.getValue(Action.NAME)); if (a.getValue(Action.ACTION_COMMAND_KEY) != null) sb.append(", Cmd=").append(a.getValue(Action.ACTION_COMMAND_KEY)); if (a.getValue(Action.SHORT_DESCRIPTION) != null) sb.append(" - ").append(a.getValue(Action.SHORT_DESCRIPTION)); System.out.println(sb.toString() + " - " + a); } } /** * Same as below KeyStroke[] kStrokes = comp.getRegisteredKeyStrokes(); if (kStrokes != null) { * System.out.println("-------------------------"); System.out.println("Registered Key Strokes - * " + comp.toString()); for (int i = 0; i < kStrokes.length; i++) { System.out.println("- " + * kStrokes[i].toString()); } } /** Focused */ InputMap im = comp.getInputMap(JComponent.WHEN_FOCUSED); KeyStroke[] kStrokes = im.allKeys(); if (kStrokes != null) { System.out.println("-------------------------"); System.out.println("InputMap for Component When Focused - " + comp.toString()); for (int i = 0; i < kStrokes.length; i++) { System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString()); } } /** Focused in Window */ im = comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); kStrokes = im.allKeys(); if (kStrokes != null) { System.out.println("-------------------------"); System.out.println("InputMap for Component When Focused in Window - " + comp.toString()); for (int i = 0; i < kStrokes.length; i++) { System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString()); } } /** Focused when Ancester */ im = comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); kStrokes = im.allKeys(); if (kStrokes != null) { System.out.println("-------------------------"); System.out.println("InputMap for Component When Ancestor - " + comp.toString()); for (int i = 0; i < kStrokes.length; i++) { System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString()); } } System.out.println("-------------------------"); } // printActionInputMap
protected void installKeyboardActions() { super.installKeyboardActions(); ActionMap map = SwingUtilities.getUIActionMap(getComponent()); if (map != null && map.get(DefaultEditorKit.selectWordAction) != null) { Action a = map.get(DefaultEditorKit.selectLineAction); if (a != null) { map.put(DefaultEditorKit.selectWordAction, a); } } }
/** * Method that returns the popup menu for a given mouse event. It will be called on each popup * event if the menu is enabled. If the menu is static caching can be used to prevent unnecessary * generation of menu objects. * * @param e Mouse event that triggered the popup menu. * @return A popup menu instance, or {@code null} if no popup menu should be shown. * @see #isPopupMenuEnabled() * @see #setPopupMenuEnabled(boolean) */ protected JPopupMenu getPopupMenu(MouseEvent e) { if (popupMenu == null) { popupMenu = new JPopupMenu(); popupMenu.add(actions.get("zoomIn")); // $NON-NLS-1$ popupMenu.add(actions.get("zoomOut")); // $NON-NLS-1$ popupMenu.add(actions.get("resetView")); // $NON-NLS-1$ popupMenu.addSeparator(); popupMenu.add(actions.get("exportImage")); // $NON-NLS-1$ popupMenu.add(actions.get("print")); // $NON-NLS-1$ } return popupMenu; }
private void configureTabbing() { KeyStroke forwardKey = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0); KeyStroke backwardKey = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0); KeyStroke spaceKey = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0); InputMap im = getInputMap(WHEN_FOCUSED); im.put(forwardKey, "go_down"); // $NON-NLS-1$ im.put(backwardKey, "go_up"); // $NON-NLS-1$ im.put(spaceKey, "select_current"); // $NON-NLS-1$ ActionMap am = getActionMap(); am.put("go_down", new MoveUpDownAction(true)); // $NON-NLS-1$ am.put("go_up", new MoveUpDownAction(false)); // $NON-NLS-1$ }
private void initActions() { @NonNls InputMap inputMap = getInputMap(WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), "moveFocusDown"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), "moveFocusUp"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "collapse"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "expand"); @NonNls ActionMap actionMap = getActionMap(); actionMap.put("moveFocusDown", new MoveFocusAction(true)); actionMap.put("moveFocusUp", new MoveFocusAction(false)); actionMap.put("collapse", new ExpandAction(false)); actionMap.put("expand", new ExpandAction(true)); }
private PauseScreen() { logger.setLevel(Level.OFF); this.setBounds( 0, 0, ScreensHolder.getInstance().getWidth(), ScreensHolder.getInstance().getHeight()); this.addMouseListener(new MouseHandler()); this.addMouseMotionListener(new MouseHandler()); InputMap imap = this.getInputMap(JComponent.WHEN_FOCUSED); imap.put(KeyStroke.getKeyStroke("ESCAPE"), "resume"); ResumeAction resume = new ResumeAction(); ActionMap amap = this.getActionMap(); amap.put("resume", resume); }