/** * Provide the standard Groovy <code>size()</code> method for <code>ButtonGroup</code>. * * @param self a ButtonGroup * @return the button count of the buttonGroup * @since 1.6.4 */ public static int size(ButtonGroup self) { return self.getButtonCount(); }
/** * Support the subscript operator for ButtonGroup. * * @param self a ButtonGroup * @param index the index of the AbstractButton to get * @return the button at the given index * @since 1.6.4 */ public static AbstractButton getAt(ButtonGroup self, int index) { int size = self.getButtonCount(); if (index < 0 || index >= size) return null; Enumeration buttons = self.getElements(); for (int i = 0; i <= index; i++) { AbstractButton b = (AbstractButton) buttons.nextElement(); if (i == index) return b; } return null; }
/** * Provide the standard Groovy <code>size()</code> method for <code>ButtonGroup</code>. * * @param self a ButtonGroup * @return the button count of the buttonGroup * @since 1.6.4 */ public static int size(ButtonGroup self) { return self.getButtonCount(); }
/** * Provide the standard Groovy <code>size()</code> method for <code>ButtonGroup</code>. * * @param self a ButtonGroup * @return the button count of the buttonGroup * @since 1.6.4 */ public static int size(ButtonGroup self) { return self.getButtonCount(); }
/** * Provide the standard Groovy <code>size()</code> method for <code>ButtonGroup</code>. * * @param self a ButtonGroup * @return the button count of the buttonGroup * @since 1.6.4 */ public static int size(ButtonGroup self) { return self.getButtonCount(); }
@Override public Component getComponent(int index) { if (index >= 0 && index < group.getButtonCount()) { return Collections.list(group.getElements()).get(index); } else { return null; } }
protected void remove( AbstractWindow w, AbstractButton b ) { final ButtonGroup g = (ButtonGroup) mapGroups.get( w ); if( g == null ) throw new IllegalArgumentException( "Element was not found : " + w ); g.remove( b ); if( g.getButtonCount() == 0 ) { mapGroups.remove( w ); } } }
/** * Support the subscript operator for ButtonGroup. * * @param self a ButtonGroup * @param index the index of the AbstractButton to get * @return the button at the given index * @since 1.6.4 */ public static AbstractButton getAt(ButtonGroup self, int index) { int size = self.getButtonCount(); if (index < 0 || index >= size) return null; Enumeration buttons = self.getElements(); for (int i = 0; i <= index; i++) { AbstractButton b = (AbstractButton) buttons.nextElement(); if (i == index) return b; } return null; }
/** * Support the subscript operator for ButtonGroup. * * @param self a ButtonGroup * @param index the index of the AbstractButton to get * @return the button at the given index * @since 1.6.4 */ public static AbstractButton getAt(ButtonGroup self, int index) { int size = self.getButtonCount(); if (index < 0 || index >= size) return null; Enumeration buttons = self.getElements(); for (int i = 0; i <= index; i++) { AbstractButton b = (AbstractButton) buttons.nextElement(); if (i == index) return b; } return null; }
protected void add( AbstractWindow w, AbstractButton b ) { ButtonGroup g = (ButtonGroup) mapGroups.get( w ); if( g == null ) { g = new ButtonGroup(); mapGroups.put( w, g ); } g.add( b ); if( g.getButtonCount() == (selected + 1) ) g.setSelected( b.getModel(), true ); }
/** * Support the subscript operator for ButtonGroup. * * @param self a ButtonGroup * @param index the index of the AbstractButton to get * @return the button at the given index * @since 1.6.4 */ public static AbstractButton getAt(ButtonGroup self, int index) { int size = self.getButtonCount(); if (index < 0 || index >= size) return null; Enumeration buttons = self.getElements(); for (int i = 0; i <= index; i++) { AbstractButton b = (AbstractButton) buttons.nextElement(); if (i == index) return b; } return null; }
private JPanel getRadioButtonsPanel() { JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(createLayout()); for (T o : values) { JRadioButton button = new JRadioButton(o.toString()); button.addItemListener(this); group.add(button); buttonsPanel.add(button); buttonToItem.put(button, o); } if(group.getButtonCount() > 0) { group.getElements().nextElement().setSelected(true); } return buttonsPanel; }
@Override public void remove(int index) { if (index >= 0 && index < group.getButtonCount()) { remove(Collections.list(group.getElements()).get(index)); } else { super.remove(index); } }
private void initFields() { for (AbstractXMPPAction action : actions.values()) { action.clearGui(); } if (actionsGroup.getButtonCount() > 0) { actionsGroup.getElements().nextElement().doClick(); } }
/** * Method is responsible for removing current JRadioButtons of ButtonGroup and * add creating the JRadioButtons and adding them to * the ButtonGroup. * * The resource name is used as the action command for the button model, * and the resource value is used to set the button label. * * @param resouces list of resource names * @param selected initially selected resource (if not null) * */ public void resetButtons(String[] resouces, String selected) { Enumeration<AbstractButton> buttons = bGroup.getElements(); List<AbstractButton> buttonsToRemove = new ArrayList<>(this.bGroup.getButtonCount()); while (buttons.hasMoreElements()) { AbstractButton abstractButton = buttons .nextElement(); buttonsToRemove.add(abstractButton); } for (AbstractButton abstractButton : buttonsToRemove) { abstractButton.removeActionListener(this); bGroup.remove(abstractButton); } for (AbstractButton abstractButton : buttonsToRemove) { this.remove(abstractButton); } initButtonGroup(resouces, selected); }
public void populateToolbar(JToolBar toolbar) { Category selected = getCategory(); // Get the NetBeans button border, if available. Border border = UIManager.getBorder("nb.tabbutton.border"); //NOI18N for (ShowCategoryAction action : categoryActions) { JToggleButton button = new JToggleButton(action); // Action has a name for accessibility purposes, but we do // not want that to appear in the button label. button.setText(null); button.getAccessibleContext().setAccessibleName(action.getCategory().getTitle()); button.setRolloverEnabled(true); if (border != null) { button.setBorder(border); } buttonGroup.add(button); if (selected == null) { if (buttonGroup.getButtonCount() == 1) { // Make the first button the chosen one. button.setSelected(true); // Select the category so it is visible. action.actionPerformed(null); } } else { if (action.getCategory().equals(selected)) { button.setSelected(true); } } toolbar.add(button); } }
depth = min(max(0, prefs.getInt("ScreenRecording.colorDepth", 3)), colorGroup.getButtonCount() - 1); setSelectedIndex(colorGroup, depth); format = min(max(0, prefs.getInt("ScreenRecording.format", 1)), formatGroup.getButtonCount() - 1); setSelectedIndex(formatGroup, format); cursor = min(max(0, prefs.getInt("ScreenRecording.cursor", 1)), cursorGroup.getButtonCount() - 1); setSelectedIndex(cursorGroup, cursor); fps = min(max(0, prefs.getInt("ScreenRecording.fps", 1)), fpsGroup.getButtonCount() - 1); setSelectedIndex(fpsGroup, fps); audioRate = min(max(0, prefs.getInt("ScreenRecording.audioRate", 1)), audioRateGroup.getButtonCount() - 1); setSelectedIndex(audioRateGroup, audioRate); channels = min(max(0, prefs.getInt("ScreenRecording.channels", 0)), channelsGroup.getButtonCount() - 1); setSelectedIndex(channelsGroup, channels); area = min(max(0, prefs.getInt("ScreenRecording.area", 0)), areaGroup.getButtonCount() - 1); setSelectedIndex(areaGroup, area);
if (pIndex==-1) for (int i= 0; i < mButtonGroup.getButtonCount(); i++)
public void actionPerformed(final ActionEvent pEvent) { ButtonModel selectedModel= mButtonGroup.getSelection(); Enumeration<AbstractButton> e = mButtonGroup.getElements(); int index = -1; for (int i= 0; i < mButtonGroup.getButtonCount(); i++) { AbstractButton button = e.nextElement(); //noinspection ObjectEquality if (button.getModel()==selectedModel) { index= i; break; } } if (index==-1) mListSelectionModel.clearSelection(); else mListSelectionModel.setSelectionInterval(index, index); handleListSelection(); } }
boolean selected = field.getSelectedIndex() == buttonGroup.getButtonCount() - 1;