/** Populate searchers. */ private void populateSearchers() { JMenu searchersMenu = this.searchersMenu; searchersMenu.removeAll(); final ToolsSettings settings = ToolsSettings.getInstance(); Collection<SearchEngine> searchEngines = settings.getSearchEngines(); SearchEngine selectedEngine = settings.getSelectedSearchEngine(); if (searchEngines != null) { for (SearchEngine se : searchEngines) { final SearchEngine finalSe = se; JRadioButtonMenuItem item = new JRadioButtonMenuItem(); item.setAction( new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { settings.setSelectedSearchEngine(finalSe); settings.save(); ComponentSource.this.updateSearchButtonTooltip(); } }); item.setSelected(se == selectedEngine); item.setText(se.getName()); item.setToolTipText(se.getDescription()); searchersMenu.add(item); } } }
public JComponent[] getMenuPresenters() { assert SwingUtilities.isEventDispatchThread() : "Must be called from AWT"; removeAll(); final TopComponent tc = WindowManager.getDefault().getRegistry().getActivated(); if (tc != null) { setEnabled(true); MultiViewHandler handler = MultiViews.findMultiViewHandler(tc); if (handler != null) { ButtonGroup group = new ButtonGroup(); MultiViewPerspective[] pers = handler.getPerspectives(); final String[] names = new String[pers.length]; for (int i = 0; i < pers.length; i++) { MultiViewPerspective thisPers = pers[i]; JRadioButtonMenuItem item = new JRadioButtonMenuItem(); names[i] = thisPers.getDisplayName(); Mnemonics.setLocalizedText(item, thisPers.getDisplayName()); item.setActionCommand(thisPers.getDisplayName()); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { MultiViewHandler handler = MultiViews.findMultiViewHandler(tc); if (handler == null) { return; } MultiViewPerspective thisPers = null; MultiViewPerspective[] pers = handler.getPerspectives(); assert pers.length == names.length : "Arrays must have the same length"; for (int i = 0; i < pers.length; i++) { if (event.getActionCommand().equals(names[i])) { thisPers = pers[i]; break; } } if (thisPers != null) { handler.requestActive(thisPers); } } }); if (thisPers .getDisplayName() .equals(handler.getSelectedPerspective().getDisplayName())) { item.setSelected(true); } group.add(item); add(item); } } else { // handler == null // No reason to enable action on any TC because now it was enabled even for Welcome page setEnabled(false); /*JRadioButtonMenuItem but = new JRadioButtonMenuItem(); Mnemonics.setLocalizedText(but, NbBundle.getMessage(EditorsAction.class, "EditorsAction.source")); but.setSelected(true); add(but);*/ } } else { // tc == null setEnabled(false); } return new JComponent[] {this}; }
public void createPopupMenu() { super.createPopupMenu(); JPopupMenu popupMenu = getPopupMenu(); if (popupMenu == null) { popupMenu = new JPopupMenu(); setPopupMenu(popupMenu); } else { popupMenu.addSeparator(); } propertiesItem = new JMenuItem("Properties ..."); propertiesItem.addActionListener(this); propertiesItem.setMnemonic('s'); popupMenu.add(propertiesItem); popupMenu.addSeparator(); ButtonGroup group = new ButtonGroup(); inItem = new JRadioButtonMenuItem("IN"); group.add(inItem); inItem.addActionListener(this); popupMenu.add(inItem); outItem = new JRadioButtonMenuItem("OUT"); group.add(outItem); outItem.addActionListener(this); popupMenu.add(outItem); inoutItem = new JRadioButtonMenuItem("INOUT"); group.add(inoutItem); inoutItem.addActionListener(this); popupMenu.add(inoutItem); }
/** Return a menu for DesktopWindow and add a special listener. */ public static JMenu getCurrencyMenu(ActionListener listener) { JRadioButtonMenuItem menuItem; String defaultCurrency = Money.getCurrencyFor(Money.getDefaultCurrency()); JMenu menu = new JMenu("Währung"); ButtonGroup group = new ButtonGroup(); JMenu europeanMenu = new JMenu("Europa"); String europeanCurrencies[] = Money.getEuropeanCurrencyList(); for (int i = 0; i < europeanCurrencies.length; i++) { menuItem = new RadioCurrencyMenuItem(europeanCurrencies[i]); menuItem.addActionListener(listener); europeanMenu.add(menuItem); group.add(menuItem); if (europeanCurrencies[i].startsWith(defaultCurrency)) { menuItem.setSelected(true); } if (i == 0) { europeanMenu.addSeparator(); } } menu.add(europeanMenu); return menu; }
@Override public void actionPerformed(ActionEvent e) { int tamanyo = 14; try { if ((JComboBox) (e.getSource()) == comboTamanyo) { tamanyo = (int) ((JComboBox) e.getSource()).getSelectedItem(); if (tamanyo == 10) jrdm10pt.setSelected(true); else if (tamanyo == 14) jrdm14pt.setSelected(true); else if (tamanyo == 18) jrdm18pt.setSelected(true); else if (tamanyo == 22) jrdm22pt.setSelected(true); } } catch (Exception ex) { } try { if ((JRadioButtonMenuItem) (e.getSource()) == jrdm10pt || (JRadioButtonMenuItem) (e.getSource()) == jrdm14pt || (JRadioButtonMenuItem) (e.getSource()) == jrdm18pt || (JRadioButtonMenuItem) (e.getSource()) == jrdm22pt) { tamanyo = Integer.parseInt(((JRadioButtonMenuItem) e.getSource()).getText()); comboTamanyo.setSelectedItem(tamanyo); } } catch (Exception ex) { } // Establecemos la acción que queremos que haga cuando se cambie Action accion = new StyledEditorKit.FontSizeAction("Tamaño", tamanyo); // Hacemos que la accion ejecute el actionPerformand accion.actionPerformed(e); jtaTexto.requestFocus(); }
private void setListeners() { // Regular items openItem.addActionListener(controller); exitItem.addActionListener(controller); connectItem.addActionListener(controller); disconnectItem.addActionListener(controller); reconnectItem.addActionListener(controller); resetItem.addActionListener(controller); // Checkboxes perspectiveItem.addActionListener(controller); sideViewitem.addActionListener(controller); topViewItem.addActionListener(controller); showGridItem.addActionListener(controller); // Radios layoutItem1.addActionListener(controller); layoutItem2.addActionListener(controller); layoutItem3.addActionListener(controller); layoutItem4.addActionListener(controller); // And more regular items settingsItem.addActionListener(controller); modeItem1.addActionListener(controller); modeItem2.addActionListener(controller); helpItem.addActionListener(controller); aboutItem.addActionListener(controller); }
public void changeDictionary(String strLanguage) { // Change dictionary MonitorDictionary.setCurrentLanguage(strLanguage); DefaultDictionary.setCurrentLanguage(strLanguage); ErrorDictionary.setCurrentLanguage(strLanguage); // Update UI updateLanguage(); WindowManager.updateLanguage(); int iIndex = mvtLanguage.indexOf(strLanguage); if (iIndex >= 0) { JRadioButtonMenuItem mnu = (JRadioButtonMenuItem) mvtLanguageItem.elementAt(iIndex); mnu.setSelected(true); } // Store config Hashtable prt = null; try { prt = Global.loadHashtable(Global.FILE_CONFIG); } catch (Exception e) { prt = new Hashtable(); } prt.put("Language", strLanguage); try { Global.storeHashtable(prt, Global.FILE_CONFIG); } catch (Exception e) { } }
protected void setProcessMenuItemsEnabled() { boolean enabled = (tabbedPane.getSelectedIndex() == TAB_INDEX_PROCESS) && sshSession.isConnected(); rdbtnmntmActiveProcesses.setEnabled(enabled); rdbtnmntmAllProcesses.setEnabled(enabled); rdbtnmntmMyProcesses.setEnabled(enabled); if ((panelProcesses != null) && panelProcesses.isRowSelected() && enabled) { mntmStopProcess.setEnabled(true); mntmContinueProcess.setEnabled(true); mntmEndProcess.setEnabled(true); mntmKillProcess.setEnabled(true); mntmChangePriority.setEnabled(true); } else { mntmStopProcess.setEnabled(false); mntmContinueProcess.setEnabled(false); mntmEndProcess.setEnabled(false); mntmKillProcess.setEnabled(false); mntmChangePriority.setEnabled(false); } }
private void computeContents() { ButtonGroup bgroup = new ButtonGroup(); bgroup.add(nullItem); removeAll(); add(minimize); add(zoom); add(close); if (!persistentItems.isEmpty()) { addSeparator(); for (JRadioButtonMenuItem item : persistentItems) { bgroup.add(item); add(item); } } if (!transientItems.isEmpty()) { addSeparator(); for (JRadioButtonMenuItem item : transientItems) { bgroup.add(item); add(item); } } WindowMenuItemManager currentManager = WindowMenuManager.getCurrentManager(); if (currentManager != null) { JRadioButtonMenuItem item = currentManager.getMenuItem(this); if (item != null) { item.setSelected(true); } } }
public int getDifficulty() { if (easy.isSelected()) { return 0; } else if (hard.isSelected()) { return 1; } else { return 2; } }
public void addRadioMenuItem(String name, String eventName, boolean isSelected) { JRadioButtonMenuItem newItem = new JRadioButtonMenuItem(name); newItem.addActionListener(this); if (isSelected == true) { newItem.setSelected(true); } this.currentButtonGroup.add(newItem); this.currentMenu.add(newItem); this.registerComponentEvent(newItem, eventName); }
@Override public void update() { super.update(); restrictDoorOptions(); north.setSelected(zone.hasDoor(ZoneModel.NORTH)); east.setSelected(zone.hasDoor(ZoneModel.EAST)); south.setSelected(zone.hasDoor(ZoneModel.SOUTH)); west.setSelected(zone.hasDoor(ZoneModel.WEST)); }
/** * createRadioButtonMenuItem * * @param ln the LineNumbersAction * @param title the label of the menuitem * @param state the state associated with the menuitem * @return JRadioButtonMenuItem */ private static JRadioButtonMenuItem createRadioButtonMenuItem(final int state) { JRadioButtonMenuItem radio = new JRadioButtonMenuItem(); radio.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { LineNumbersAction.setState(state); } }); return radio; }
/** * @param text * @param cmdName * @param group * @param icon * @return */ public static JRadioButtonMenuItem createRadioMenuItem( String text, String cmdName, ButtonGroup group, ImageIcon icon) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(text); item.setActionCommand(cmdName); if (group != null) { group.add(item); } if (icon != null) { item.setIcon(icon); } return item; }
private ButtonGroup createButtonGroup() { ButtonGroup g1 = new ButtonGroup(); for (int j = 0; j < 4; j++) for (int i = 0; i < 16; i++) { JRadioButtonMenuItem b = new JRadioButtonMenuItem(new PopupIcon(i + 16 * j)); b.setSelectedIcon(null); b.addActionListener(this::doSelect); this.add(b); g1.add(b); } return g1; }
/** Initialize and update the items. */ @Override public void initItems() { if (!initialized) { return; } removeAll(); JMenuItem mit = add(newWindowAction); setMenuShortCutAccelerator(mit, 'N'); ArrayList<GeoGebraFrame> ggbInstances = GeoGebraFrame.getInstances(); int size = ggbInstances.size(); if (size == 1) return; addSeparator(); StringBuilder sb = new StringBuilder(); ButtonGroup bg = new ButtonGroup(); JRadioButtonMenuItem mi; int current = -1; for (int i = 0; i < size; i++) { GeoGebraFrame ggb = ggbInstances.get(i); AppD application = ggb.getApplication(); if (app == application) current = i; } for (int i = 0; i < size; i++) { GeoGebraFrame ggb = ggbInstances.get(i); AppD application = ggb.getApplication(); sb.setLength(0); sb.append(i + 1); if (application != null) // Michael Borcherds 2008-03-03 bugfix if (application.getCurrentFile() != null) { sb.append(" "); sb.append(application.getCurrentFile().getName()); } mi = new JRadioButtonMenuItem(sb.toString()); if (application == this.app) mi.setSelected(true); ActionListener al = new RequestFocusListener(ggb); mi.addActionListener(al); if (i == ((current + 1) % size)) setMenuShortCutShiftAccelerator(mi, 'N'); else if (i == ((current - 1 + size) % size)) setMenuShortCutShiftAltAccelerator(mi, 'N'); bg.add(mi); add(mi); } // support for right-to-left languages app.setComponentOrientation(this); }
public void carregarAcoes() { check0_001.addActionListener( actionEvent -> { String codigo = Parametro.CARREGAR_RDF_GERADO; String valor = String.valueOf(check0_001.isSelected()); configuracoes.put(codigo, valor); }); check0_003.addActionListener( actionEvent -> { String codigo = Parametro.VALIDAR_TODOS_METADADOS; String valor = String.valueOf(check0_003.isSelected()); configuracoes.put(codigo, valor); }); check0_005.addActionListener( actionEvent -> { String codigo = Parametro.PERGUNTAR_SINTAXE_RDF; item1.setEnabled(check0_005.isSelected()); item2.setEnabled(check0_005.isSelected()); String valor = String.valueOf(check0_005.isSelected()); configuracoes.put(codigo, valor); }); final JDialog dialogo = this; // Irá aplicar as configurações e sair botaoOk.addActionListener( actionEvent -> { try { SenseUtil.validarEndereco(caixa0_004.getText()); } catch (SenseRDFException se) { JOptionPane.showMessageDialog( null, se.getMessage(), Sap.ERRO.get(), JOptionPane.ERROR_MESSAGE); return; } aplicarConfiguracoes = true; aplicarConfiguracoes(); dialogo.dispose(); }); // Ao clicar em cancelar não se deve fazer nada botaoCancelar.addActionListener( actionEvent -> { aplicarConfiguracoes = false; dialogo.dispose(); }); }
/** * create (if necessary) and return a menu that will change the mode * * @return the menu */ @Override public JMenu getModeMenu() { if (modeMenu == null) { modeMenu = new JMenu(); // { Icon icon = BasicIconFactory.getMenuArrowIcon(); modeMenu.setIcon(BasicIconFactory.getMenuArrowIcon()); modeMenu.setPreferredSize(new Dimension(icon.getIconWidth() + 10, icon.getIconHeight() + 10)); final JRadioButtonMenuItem transformingButton = new JRadioButtonMenuItem(Mode.TRANSFORMING.toString()); transformingButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { setMode(Mode.TRANSFORMING); } } }); final JRadioButtonMenuItem pickingButton = new JRadioButtonMenuItem(Mode.PICKING.toString()); pickingButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { setMode(Mode.PICKING); } } }); ButtonGroup radio = new ButtonGroup(); radio.add(transformingButton); radio.add(pickingButton); transformingButton.setSelected(true); modeMenu.add(transformingButton); modeMenu.add(pickingButton); modeMenu.setToolTipText("Menu for setting Mouse Mode"); addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getItem() == Mode.TRANSFORMING) { transformingButton.setSelected(true); } else if (e.getItem() == Mode.PICKING) { pickingButton.setSelected(true); } } } }); } return modeMenu; }
public void setScores() { p1Stats.setForeground(Color.white); p2Stats.setForeground(Color.white); p1Stats.setText("Player 1| Wins: " + TTTMain.p1WinCount + " Loss: " + TTTMain.p1LossCount); p2Stats.setText("Player 2| Wins: " + TTTMain.p2WinCount + " Loss: " + TTTMain.p2LossCount); if (p1.isSelected()) { TTTMain.aiEnabled = true; p2Stats.setVisible(false); } else if (p2.isSelected()) { TTTMain.aiEnabled = false; p2Stats.setVisible(true); } }
/** Creates a JRadioButtonMenuItem for the Themes menu */ private JMenuItem createThemesMenuItem( JMenu menu, String label, char mnemonic, String accessibleDescription, DefaultMetalTheme theme) { JRadioButtonMenuItem mi = (JRadioButtonMenuItem) menu.add(new JRadioButtonMenuItem(label)); themesMenuGroup.add(mi); mi.setMnemonic(mnemonic); mi.getAccessibleContext().setAccessibleDescription(accessibleDescription); mi.addActionListener(new ChangeThemeAction(this, theme)); return mi; }
/** * Creates and returns a new swing radio button menu item * * @param name the name of the menu item * @throws MissingResourceException if one of the keys that compose the menu item is missing. It * is not thrown if the mnemonic, the accelerator and the action keys are missing * @throws ResourceFormatException if the mnemonic is not a single character. * @throws MissingListenerException if then item action is not found in the action map. */ public JRadioButtonMenuItem createJRadioButtonMenuItem(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException { JRadioButtonMenuItem result; result = new JRadioButtonMenuItem(getString(name + TEXT_SUFFIX)); initializeJMenuItem(result, name); // is the item selected? try { result.setSelected(getBoolean(name + SELECTED_SUFFIX)); } catch (MissingResourceException e) { } return result; }
@Override public void actionPerformed(ActionEvent ae) { Object source = ae.getSource(); if (source == authorMenuItem) { authorFrame.setVisible(true); } else if (source == problemMenuItem) { problemFrame.setVisible(true); } if (source instanceof JRadioButtonMenuItem) { if (ricartAgrawala.isSelected()) vizPanel.setMethod("ricart-agrawala"); else if (modRicartAgrawala.isSelected()) vizPanel.setMethod("modified ricart-agrawala"); else System.out.println("ERROR: Setting method: no recognized method."); } }
public int showProcessesType() { if (rdbtnmntmActiveProcesses.isSelected()) { return ACTIVE_PROCESS; } else if (rdbtnmntmAllProcesses.isSelected()) { return ALL_PROCESS; } else if (rdbtnmntmMyProcesses.isSelected()) { return MY_PROCESS; } return ALL_PROCESS; }
private static JMenu getMenu_ThemeOptions() { final JMenu menu = new JMenu("Theme"); JRadioButtonMenuItem menuItem; final ButtonGroup group = new ButtonGroup(); final String currentSkin = prefs.getPref(FPref.UI_SKIN); for (final String skin : FSkin.getAllSkins()) { menuItem = new JRadioButtonMenuItem(skin); group.add(menuItem); if (skin.equals(currentSkin)) { menuItem.setSelected(true); } menuItem.setActionCommand(skin); menuItem.addActionListener(changeSkin); menu.add(menuItem); } return menu; }
public TreeElementMenu( MainFrame _frame, TopiaryWindow _parent, String name, ColorPanel _colorPanel, int elementType) { super(name); parent = _parent; frame = _frame; tree = ((TreeWindow) parent).tree; noColoringMenuItem.addActionListener(this); add(noColoringMenuItem); majorityColoringMenuItem.addActionListener(this); add(majorityColoringMenuItem); colorBy = new ColorByMenu(frame, parent, _colorPanel, elementType); add(colorBy); }
/** * This method initializes jRadioButtonMenuItem1 * * @return JRadioButtonMenuItem */ private JRadioButtonMenuItem getJRadioButtonMenuItem1() { if (jRadioButtonMenuItem1 == null) { jRadioButtonMenuItem1 = new JRadioButtonMenuItem(); jRadioButtonMenuItem1.setText("System"); jRadioButtonMenuItem1.setMnemonic(java.awt.event.KeyEvent.VK_Y); jRadioButtonMenuItem1.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_Y, java.awt.Event.ALT_MASK, false)); jRadioButtonMenuItem1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { changeLnF(UIManager.getSystemLookAndFeelClassName()); } }); } return jRadioButtonMenuItem1; }
private JRadioButtonMenuItem getJRadioButtonMenuItemUpdateContact() { if (jRadioButtonMenuItemUpdateContact == null) { jRadioButtonMenuItemUpdateContact = new JRadioButtonMenuItem(); jRadioButtonMenuItemUpdateContact.setText("Details"); jRadioButtonMenuItemUpdateContact.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final String id = (String) jTableContactsModel.getValueAt(row, 0); // contact // number final Contact contact = ContactController.getContact(id); new JDialogContact(customer, contact, CRUDOperationEnum.UPDATE); refillContactsView(); } }); } return jRadioButtonMenuItemUpdateContact; }
/** * This method initializes jRadioButtonMenuItem * * @return JRadioButtonMenuItem */ private JRadioButtonMenuItem getJRadioButtonMenuItem() { if (jRadioButtonMenuItem == null) { jRadioButtonMenuItem = new JRadioButtonMenuItem(); jRadioButtonMenuItem.setText("Default"); jRadioButtonMenuItem.setSelected(true); jRadioButtonMenuItem.setAccelerator( javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_D, java.awt.Event.ALT_MASK, false)); jRadioButtonMenuItem.setMnemonic(java.awt.event.KeyEvent.VK_D); jRadioButtonMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { changeLnF(UIManager.getCrossPlatformLookAndFeelClassName()); } }); } return jRadioButtonMenuItem; }
private JRadioButtonMenuItem getJRadioButtonMenuItemDeleteContact() { if (jRadioButtonMenuItemDeleteContact == null) { jRadioButtonMenuItemDeleteContact = new JRadioButtonMenuItem(); jRadioButtonMenuItemDeleteContact.setText("Verwijderen"); jRadioButtonMenuItemDeleteContact.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final String id = (String) jTableContactsModel.getValueAt(row, 0); // contact final int response = JOptionPaneItemRemove.confirm(" contact " + id); if (response == JOptionPane.YES_OPTION) { ContactController.removeContact(id); refillContactsView(); } } }); } return jRadioButtonMenuItemDeleteContact; }
private JRadioButtonMenuItem getJRadioButtonMenuItemUpdateAddress() { if (jRadioButtonMenuItemUpdateAddress == null) { jRadioButtonMenuItemUpdateAddress = new JRadioButtonMenuItem(); jRadioButtonMenuItemUpdateAddress.setText("Details"); jRadioButtonMenuItemUpdateAddress.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final String id = (String) jTableAddressModel.getValueAt(row, 0); // product // number final Address address = AddressController.getAddress(id); new JDialogAddress(customer, address, CRUDOperationEnum.UPDATE); refillAddressView(); } }); } return jRadioButtonMenuItemUpdateAddress; }