List of usage examples for javax.swing AbstractButton setSelected
public void setSelected(boolean b)
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setSelected(true); System.out.println(jb.getVerticalAlignment()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);/*from w ww . j a v a 2s . c om*/ f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JToggleButton("Press Me"); jb.setSelected(true); System.out.println(jb.getIconTextGap()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb);/*w ww . j a v a2s . c om*/ f.pack(); f.setVisible(true); }
From source file:Main.java
public static void setSelected(final boolean isSelected, final AbstractButton... components) { for (final AbstractButton button : components) { button.setSelected(isSelected); }/* w w w .j a v a2 s .co m*/ }
From source file:Main.java
private static void doSetSelectedInEDT(final AbstractButton abstractButton, final boolean isSelected) { abstractButton.setSelected(isSelected); }
From source file:Main.java
/** * Thread-friendly wrapper method for <code>AbstractButton.setSelected</code>. * @param selected//from w ww .j a v a 2s.co m * @param buttons AbstractButtons to select/deselect * * @see javax.swing.AbstractButton.setSelected(boolean) * @deprecated */ @Deprecated public static void setSelected(final boolean selected, final AbstractButton... buttons) { Runnable r = new Runnable() { public void run() { for (AbstractButton button : buttons) { button.setSelected(selected); } } }; if (EventQueue.isDispatchThread()) { r.run(); return; } runTask(r, true); }
From source file:Main.java
/** * select silently/*from www. j a v a 2 s. c o m*/ * @param aButton button * @param isSelected indicates if button should be selected * @param aListener listener to be removed when selecting index */ public final static void SelectSilently(AbstractButton aButton, boolean isSelected, ActionListener aListener) { aButton.removeActionListener(aListener); aButton.setSelected(isSelected); aButton.addActionListener(aListener); }
From source file:Main.java
public static void setSelected(final AbstractButton abstractButton, final boolean isSelected) { if (abstractButton != null) { runInEDT(() -> abstractButton.setSelected(isSelected)); }/*from www .jav a 2s. com*/ }
From source file:com.projity.menu.MenuManager.java
public void setActionSelected(String id, boolean enable) { Collection buttons = toolBarFactory.getButtonsFromId(id); if (buttons != null) { Iterator i = buttons.iterator(); while (i.hasNext()) { AbstractButton button = (AbstractButton) i.next(); if (button != null) { button.setSelected(enable); if (button instanceof JToggleButton) { // button.setBackground(enable ? Color.GRAY : ExtButtonFactory.BACKGROUND_COLOR); }/*from w w w .j a va2 s. c o m*/ } } } JMenuItem menuItem = menuFactory.getMenuItemFromId(id); if (menuItem != null) menuItem.setSelected(enable); Iterator i = tabbedNavigations.iterator(); while (i.hasNext()) ((TabbedNavigation) i.next()).setActivatedView(id, enable); }
From source file:net.sourceforge.pmd.util.designer.Designer.java
private void loadSettings() { File file = new File(SETTINGS_FILE_NAME); if (file.exists()) { try (InputStream stream = Files.newInputStream(file.toPath())) { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document document = builder.parse(stream); Element settingsElement = document.getDocumentElement(); Element codeElement = (Element) settingsElement.getElementsByTagName("code").item(0); Element xpathElement = (Element) settingsElement.getElementsByTagName("xpath").item(0); String code = getTextContext(codeElement); String languageVersion = codeElement.getAttribute("language-version"); String xpath = getTextContext(xpathElement); String xpathVersion = xpathElement.getAttribute("version"); codeEditorPane.setText(code); setLanguageVersion(LanguageRegistry.findLanguageVersionByTerseName(languageVersion)); xpathQueryArea.setText(xpath); for (Enumeration<AbstractButton> e = xpathVersionButtonGroup.getElements(); e.hasMoreElements();) { AbstractButton button = e.nextElement(); if (xpathVersion.equals(button.getActionCommand())) { button.setSelected(true); break; }/* w w w. j a v a 2s. c o m*/ } } catch (ParserConfigurationException | IOException | SAXException e) { e.printStackTrace(); } } }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Updates UI components when a new color model is selected. * // w w w . ja v a 2 s.c o m * @param key The index of the color model. */ void setColorModel(int key) { controlPane.setColorModel(); AbstractButton b; Action a; Enumeration<AbstractButton> e; for (e = colorModelGroup.getElements(); e.hasMoreElements();) { b = e.nextElement(); a = b.getAction(); if (a instanceof ColorModelAction) { b.removeActionListener(a); b.setSelected(((ColorModelAction) a).getIndex() == key); b.setAction(a); } } }