List of usage examples for javax.swing Action SELECTED_KEY
String SELECTED_KEY
To view the source code for javax.swing Action SELECTED_KEY.
Click Source Link
Boolean
that corresponds to the selected state. From source file:Main.java
public ShowAction() { super("About"); putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A)); putValue(Action.NAME, "Go to number "); putValue(Action.SELECTED_KEY, true); }
From source file:dmh.swing.enumselect.EnumSelectAction.java
@Override public void update(Observable o, Object arg) { putValue(Action.SELECTED_KEY, (enumValue == arg)); }
From source file:Main.java
/** * Creates a suitable menu item.//from ww w . j a v a 2 s . co m * * @param action * @return */ public static JMenuItem createMenuItem(Action action) { final JMenuItem mi; final Boolean selected = (Boolean) action.getValue(Action.SELECTED_KEY); if (selected != null) { mi = new JCheckBoxMenuItem(action); } else { mi = new JMenuItem(action); } mi.setHorizontalTextPosition(JButton.TRAILING); mi.setVerticalTextPosition(JButton.CENTER); return mi; }
From source file:Main.java
/** * //from w w w.j a va2s .c o m * TODO * @param action * @return */ public static AbstractButton createToolbarItem(Action action) { final AbstractButton button; if (action == null) { throw new NullPointerException("Action cannot be null!"); } else if (action.getValue(Action.SELECTED_KEY) != null) { button = new JToggleButton(action); } else { button = new JButton(action); } button.setOpaque(false); // hide text if icon is available if (action != null && (action.getValue(Action.SMALL_ICON) != null || action.getValue(Action.LARGE_ICON_KEY) != null)) { button.setHideActionText(true); } button.setHorizontalTextPosition(JButton.CENTER); button.setVerticalTextPosition(JButton.BOTTOM); return button; }
From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
/** * Fetches the command list for the FilePane. These commands * are useful for binding to events, such as in a keymap. * * @return the command list//from ww w .j a v a 2 s . c o m */ public Action[] getActions() { if (actions == null) { class FilePaneAction extends AbstractAction { FilePaneAction(String name) { this(name, name); } FilePaneAction(String name, String cmd) { super(name); putValue(Action.ACTION_COMMAND_KEY, cmd); } public void actionPerformed(ActionEvent e) { String cmd = (String) getValue(Action.ACTION_COMMAND_KEY); if (cmd.equals(ACTION_CANCEL)) { if (editFile != null) { cancelEdit(); } else { getFileChooser().cancelSelection(); } } else if (cmd.equals(ACTION_EDIT_FILE_NAME)) { VFSJFileChooser fc = getFileChooser(); int index = listSelectionModel.getMinSelectionIndex(); if ((index >= 0) && (editFile == null) && (!fc.isMultiSelectionEnabled() || (fc.getSelectedFiles().length <= 1))) { editFileName(index); } } else if (cmd.equals(ACTION_REFRESH)) { getFileChooser().rescanCurrentDirectory(); } else if (cmd.equals(ACTION_VIEW_HIDDEN)) { getFileChooser().setFileHidingEnabled(!getFileChooser().isFileHidingEnabled()); } } @Override public boolean isEnabled() { String cmd = (String) getValue(Action.ACTION_COMMAND_KEY); if (cmd.equals(ACTION_CANCEL)) { return getFileChooser().isEnabled(); } else if (cmd.equals(ACTION_EDIT_FILE_NAME)) { return !readOnly && getFileChooser().isEnabled(); } else { return true; } } } ArrayList<Action> actionList = new ArrayList<Action>(8); Action action; actionList.add(new FilePaneAction(ACTION_CANCEL)); actionList.add(new FilePaneAction(ACTION_EDIT_FILE_NAME)); FilePaneAction showHidden = new FilePaneAction(showHiddenFilesLabelText, ACTION_VIEW_HIDDEN); showHidden.putValue(Action.SELECTED_KEY, false); actionList.add(showHidden); actionList.add(new FilePaneAction(refreshActionLabelText, ACTION_REFRESH)); action = fileChooserUIAccessor.getApproveSelectionAction(); if (action != null) { actionList.add(action); } action = fileChooserUIAccessor.getChangeToParentDirectoryAction(); if (action != null) { actionList.add(action); } action = getNewFolderAction(); if (action != null) { actionList.add(action); } action = getViewTypeAction(VIEWTYPE_LIST); if (action != null) { actionList.add(action); } actions = actionList.toArray(new Action[actionList.size()]); } return actions.clone(); }
From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
@Override public JPopupMenu getComponentPopupMenu() { JPopupMenu popupMenu = getFileChooser().getComponentPopupMenu(); if (popupMenu != null) { return popupMenu; }/*from w w w .j a v a2s .c o m*/ JMenu aViewMenu = getViewMenu(); if (contextMenu == null) { contextMenu = new JPopupMenu(); if (aViewMenu != null) { contextMenu.add(aViewMenu); if (listViewWindowsStyle) { contextMenu.addSeparator(); } } ActionMap actionMap = getActionMap(); Action refreshAction = actionMap.get(ACTION_REFRESH); Action aNewFolderAction = actionMap.get(ACTION_NEW_FOLDER); Action showHiddenFiles = actionMap.get(ACTION_VIEW_HIDDEN); if (refreshAction != null) { contextMenu.add(refreshAction); if (listViewWindowsStyle && (aNewFolderAction != null)) { contextMenu.addSeparator(); } } if (showHiddenFiles != null) { JCheckBoxMenuItem menuitem = new JCheckBoxMenuItem(showHiddenFiles); menuitem.setSelected((Boolean) showHiddenFiles.getValue(Action.SELECTED_KEY)); contextMenu.add(menuitem); } if (aNewFolderAction != null) { contextMenu.add(aNewFolderAction); } } if (aViewMenu != null) { aViewMenu.getPopupMenu().setInvoker(aViewMenu); } return contextMenu; }
From source file:net.sf.jabref.gui.JabRefFrame.java
private static Action enableToggle(Action a, boolean initialValue) { // toggle only works correctly when the SELECTED_KEY is set to false or true explicitly upon start a.putValue(Action.SELECTED_KEY, String.valueOf(initialValue)); return a;/* w w w.j a v a 2s . c o m*/ }
From source file:org.pentaho.reporting.designer.core.xul.ActionSwingMenuitem.java
protected void installAction(final Action newAction) { if (newAction != null) { menuitem.addActionListener(newAction); newAction.addPropertyChangeListener(actionChangeHandler); setLabel((String) (newAction.getValue(Action.NAME))); setTooltiptext((String) (newAction.getValue(Action.SHORT_DESCRIPTION))); setDisabled(this.action.isEnabled() == false); refreshMnemonic(newAction);//from w ww .ja va2s. c om refreshKeystroke(newAction); final Object rawSelectedSwing = action.getValue(Action.SELECTED_KEY); if (rawSelectedSwing != null) { setSelected(Boolean.TRUE.equals(rawSelectedSwing)); } else { final Object rawSelectedPrd = action.getValue("selected"); setSelected(Boolean.TRUE.equals(rawSelectedPrd)); } final Object rawVisible = action.getValue("visible"); if (rawVisible != null) { setVisible(Boolean.TRUE.equals(rawVisible)); } } }
From source file:se.trixon.jota.client.ui.MainFrame.java
@Override public void onServerEvent(ServerEvent serverEvent) { switch (serverEvent) { case CRON_CHANGED: try {//from w w w . j a v a 2 s . co m boolean cronActive = mManager.getServerCommander().isCronActive(); mActionManager.getAction(ActionManager.CRON).putValue(Action.SELECTED_KEY, cronActive); } catch (RemoteException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } break; case JOTA_CHANGED: loadConfiguration(); break; case SHUTDOWN: mShutdownInProgress = true; mManager.disconnect(); break; default: throw new AssertionError(); } }
From source file:se.trixon.jota.client.ui.MainFrame.java
private void enableGui(boolean state) { boolean cronActive = false; try {/*from w ww.java 2s . c om*/ cronActive = state && mManager.getServerCommander().isCronActive(); } catch (RemoteException ex) { } mActionManager.getAction(ActionManager.CRON).putValue(Action.SELECTED_KEY, cronActive); mServerActions.stream().forEach((action) -> { action.setEnabled(state); }); mActionManager.getAction(ActionManager.CLOSE_TAB).setEnabled(false); mActionManager.getAction(ActionManager.SAVE_TAB).setEnabled(false); if (state) { updateWindowTitle(); } else { setTitle("Jotasync"); } }