Java Code Examples for javax.swing.JRadioButton#isSelected()

The following examples show how to use javax.swing.JRadioButton#isSelected() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SessionAnalysisWorkflowManagerLAICPMS.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void refreshView() {
    Enumeration buttons = includedFractions_buttonGroup.getElements();
    while (buttons.hasMoreElements()) {
        JRadioButton b = (JRadioButton) buttons.nextElement();
        if (b.isSelected()) {
            b.doClick();
            break;
        }
    }

    if (((TripoliSessionRawDataView) tripoliSessionRawDataView).isSAVED_YAXIS_IS_UNIFORM()) {
        uniformYaxis.doClick();
    } else {
        independentYaxis.doClick();
    }

    if (((TripoliSessionRawDataView) tripoliSessionRawDataView).getSAVED_DATA_USED_FOR_SCALING().equals(IncludedTypeEnum.ALL)) {
        allDataUsedForScaling.doClick();
    } else {
        includedDataUsedForScaling.doClick();
    }

}
 
Example 2
Source File: VideoIO.java    From osp with GNU General Public License v3.0 6 votes vote down vote up
/**
  * Gets the selected video engine type.
  * 
  * @return the video engine type
  */  
public VideoType getSelectedVideoType() {
	if (chooser.getAccessory()==null
			|| chooser.getAccessory()==emptyPanel)
		return null;
   for (JRadioButton button: buttonMap.keySet()) {
   	if (button.isSelected()) {
   		VideoType engineType = buttonMap.get(button);
   		OSPLog.finest("selected video type: "+engineType); //$NON-NLS-1$
   		String engineName = engineType.getClass().getSimpleName();
   		String ext = XML.getExtension(selectedFile.getName());
   		VideoType specificType = getVideoType(engineName, ext);
   		return specificType==null? engineType: specificType;
   	}
   }
   return null;
}
 
Example 3
Source File: SessionAnalysisWorkflowManagerSHRIMP.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void refreshView() {
    Enumeration buttons = includedFractions_buttonGroup.getElements();
    while (buttons.hasMoreElements()) {
        JRadioButton b = (JRadioButton) buttons.nextElement();
        if (b.isSelected()) {
            b.doClick();
            break;
        }
    }

    if (((TripoliSessionRawDataView) tripoliSessionRawDataView).isSAVED_YAXIS_IS_UNIFORM()) {
        uniformYaxis.doClick();
    } else {
        independentYaxis.doClick();
    }

    if (((TripoliSessionRawDataView) tripoliSessionRawDataView).getSAVED_DATA_USED_FOR_SCALING().equals(IncludedTypeEnum.ALL)) {
        allDataUsedForScaling.doClick();
    } else {
        includedDataUsedForScaling.doClick();
    }

}
 
Example 4
Source File: right_JXButtonGroupPanel_1.3.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
protected boolean accept(Component c) {
    for (int i = 0; i < group.length; i++) {
        if (isSkipUnselected && group[i].contains(c)) {
            JRadioButton b = (JRadioButton) c;
            if (group[i].getSelection() != null && !b.isSelected()) {
                return false;
            }
        }
    }
    return super.accept(c);
}
 
Example 5
Source File: SwingRadioButtonListWidget.java    From atdl4j with MIT License 5 votes vote down vote up
public String getControlValueRaw()
{
	for ( int i = 0; i < this.buttons.size(); i++ )
	{
		JRadioButton b = buttons.get( i );
		if ( b.isSelected() )
		{
			return ( (RadioButtonListT) control ).getListItem().get( i ).getEnumID();
		}
	}
	return null;
}
 
Example 6
Source File: GatewayLoginFrameHandler.java    From ib-controller with GNU General Public License v3.0 5 votes vote down vote up
private void switchToIBAPI(Window window) throws IBControllerException {
    JRadioButton button = SwingUtils.findRadioButton(window, "IB API");
    if (button == null) button = SwingUtils.findRadioButton(window, "TWS/API") ;
    if (button == null) throw new IBControllerException("IB API radio button");
    
    if (! button.isSelected()) button.doClick();
}
 
Example 7
Source File: LayoutControlPanel.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    JRadioButton rb = (JRadioButton) e.getSource();
    if(!rb.isSelected()) {
               return;
           }
           String cmd = rb.getActionCommand();
           int hPos, vPos;
           if(cmd.equals("NW")) {
                   hPos = LEFT; vPos = TOP;
           } else if(cmd.equals("N")) {
                   hPos = CENTER; vPos = TOP;
           } else if(cmd.equals("NE")) {
                   hPos = RIGHT; vPos = TOP;
           } else if(cmd.equals("W")) {
                   hPos = LEFT; vPos = CENTER;
           } else if(cmd.equals("C")) {
                   hPos = CENTER; vPos = CENTER;
           } else if(cmd.equals("E")) {
                   hPos = RIGHT; vPos = CENTER;
           } else if(cmd.equals("SW")) {
                   hPos = LEFT; vPos = BOTTOM;
           } else if(cmd.equals("S")) {
                   hPos = CENTER; vPos = BOTTOM;
           } else /*if(cmd.equals("SE"))*/ {
                   hPos = RIGHT; vPos = BOTTOM;
           }
           for(int i = 0; i < demo.getCurrentControls().size(); i++) {
               Component c = (Component) demo.getCurrentControls().elementAt(i);
               setPosition(c, hPos, vPos);
           }
           demo.invalidate();
           demo.validate();
           demo.repaint();
}
 
Example 8
Source File: StockpileImportDialog.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
private void selected(JRadioButton jRadioButton, ImportReturn single, ImportReturn all) {
	if (jRadioButton.isSelected()) {
		if (jAll.isSelected()) {
			importReturn = all;
		} else {
			importReturn = single;
		}
	}
}
 
Example 9
Source File: SelectionDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Checks, if the specified radio button containing the i18n String of the given key is
 * selected.
 *
 * @param key
 *            i18n key
 * @return true, if a matching radio button is selected
 */
public boolean isOptionSelected(String key) {
	for (int i = 0; i < selectionPanel.getComponents().length; i++) {
		JRadioButton radioButton = (JRadioButton) selectionPanel.getComponent(i);
		if (radioButton.getText().equals(getI18n(key))) {
			if (radioButton.isSelected()) {
				return true;
			} else {
				return false;
			}
		}
	}
	return false;
}
 
Example 10
Source File: SelectionDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Checks, if the specified radio button is selected.
 *
 * @param index
 *            Index of the radio button to examine
 * @return true, if the radio button is selected
 */
public boolean isOptionSelected(int index) {
	if (index >= selectionPanel.getComponents().length) {
		return false;
	}
	JRadioButton radioButton = (JRadioButton) selectionPanel.getComponent(index);
	if (radioButton.isSelected()) {
		return true;
	} else {
		return false;
	}
}
 
Example 11
Source File: BlazeAndroidTestRunConfigurationStateEditor.java    From intellij with Apache License 2.0 5 votes vote down vote up
private int getTestingType() {
  for (int i = 0, myTestingType2RadioButtonLength = testingType2RadioButton.length;
      i < myTestingType2RadioButtonLength;
      i++) {
    JRadioButton button = testingType2RadioButton[i];
    if (button.isSelected()) {
      return i;
    }
  }
  return -1;
}
 
Example 12
Source File: Reset.java    From netbeans with Apache License 2.0 5 votes vote down vote up
ResetType getType () {
    String cmd = null;
    for (JRadioButton btn : new JRadioButton[] { panel.rbHard, panel.rbMixed, panel.rbSoft }) {
        if (btn.isSelected()) {
            cmd = btn.getActionCommand();
            break;
        }
    }
    return ResetType.valueOf(cmd);
}
 
Example 13
Source File: Query.java    From OpenDA with GNU Lesser General Public License v3.0 4 votes vote down vote up
/** Get the current value in the entry with the given name,
 *  and return as a String.  All entry types support this.
 *  Note that this method should be called from the event dispatch
 *  thread, since it needs to query to UI widgets for their current
 *  values.  If it is called from another thread, there is no
 *  assurance that the value returned will be the current value.
 *  @return The value currently in the entry as a String.
 *  @exception NoSuchElementException If there is no item with the
 *   specified name.  Note that this is a runtime exception, so it
 *   need not be declared explicitly.
 *  @exception IllegalArgumentException If the entry type does not
 *   have a string representation (this should not be thrown).
 */
public String getStringValue(String name)
    throws NoSuchElementException, IllegalArgumentException {
    Object result = _entries.get(name);
    if (result == null) {
        throw new NoSuchElementException(
            "No item named \"" + name + " \" in the query box.");
    }
    // FIXME: Surely there is a better way to do this...
    // We should define a set of inner classes, one for each entry type.
    // Currently, this has to be updated each time a new entry type
    // is added.
    if (result instanceof JTextField) {
        return ((JTextField) result).getText();
    } else if (result instanceof QueryColorChooser) {
        return ((QueryColorChooser) result).getSelectedColor();
    } else if (result instanceof QueryFileChooser) {
        return ((QueryFileChooser) result).getSelectedFileName();
    } else if (result instanceof JTextArea) {
        return ((JTextArea) result).getText();
    } else if (result instanceof JRadioButton) {
        JRadioButton radioButton = (JRadioButton) result;
        if (radioButton.isSelected()) {
            return "true";
        } else {
            return "false";
        }
    } else if (result instanceof JSlider) {
        return "" + ((JSlider) result).getValue();
    } else if (result instanceof JComboBox) {
        return (String) (((JComboBox) result).getSelectedItem());
    } else if (result instanceof JRadioButton[]) {
        // Regrettably, ButtonGroup gives no way to determine
        // which button is selected, so we have to search...
        JRadioButton[] buttons = (JRadioButton[]) result;
        String toReturn = null;
        for (int i = 0; i < buttons.length; i++) {
            if (buttons[i].isSelected()) {
                if (toReturn == null)
                    toReturn = buttons[i].getText();
                else
                    toReturn = toReturn + ", " + buttons[i].getText();
            }
        }
        if (toReturn == null)
            toReturn = "";
        return toReturn;
    } else if (result instanceof QueryScrollPane) {
        return ((QueryScrollPane) result).getText();
    } else {
        throw new IllegalArgumentException(
            "Query class cannot generate"
                + " a string representation for entries of type "
                + result.getClass());
    }
}
 
Example 14
Source File: CasAnnotationViewer.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * Check if an annotation matches the filters set by the user. If true, the
 * annotation will be added to the annotation tree display panel.
 *
 * @param annotation the annotation
 * @return true, if is match
 */
private boolean isMatch(Annotation annotation) {
  Type type = annotation.getType();
  switch (this.viewMode) {
    case MODE_ANNOTATIONS:
      if (this.typeToCheckBoxMap.size() == 0) {
        return false;
      }
      JCheckBox typeCheckBox = this.typeToCheckBoxMap.get(type);
      return typeCheckBox != null && typeCheckBox.isSelected();
    case MODE_ENTITIES:
      if (this.entityToCheckBoxMap.size() == 0) {
        return false;
      }
      Entity entity = this.entityResolver.getEntity(annotation);
      if (entity == null) {
        return false;
      }
      JCheckBox entityCheckBox = this.entityToCheckBoxMap.get(entity);
      return entityCheckBox != null && entityCheckBox.isSelected();
    case MODE_FEATURES:
      JRadioButton typeRadioButton = this.typeRadioButtonMap.get(type);
      if (typeRadioButton == null || !typeRadioButton.isSelected()) {
        return false;
      }
      List<Feature> features = type.getFeatures();
      if (features == null || features.size() == 0) {
        return false;
      }
      for (Feature feature : features) {
        String featureName = feature.getShortName();
        if (featureName == null || featureName.length() == 0) {
          continue;
        }
        JRadioButton featureRadioButton = this.featureRadioButtonMap.get(featureName);
        if (featureRadioButton == null || !featureRadioButton.isSelected()) {
          continue;
        }
        String featureValue = this.getFeatureValueInString(annotation, feature);
        if (featureValue == null || featureValue.length() == 0) {
          continue;
        }
        JCheckBox featureValueCheckBox = this.featureValueCheckBoxMap.get(featureValue);
        return featureValueCheckBox != null && featureValueCheckBox.isSelected();
      }
      break;
    default:
      break;
  }
  return false;
}
 
Example 15
Source File: GroovyJUnitTestWizard.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private JUnit askUserWhichJUnitToUse() {
    JRadioButton radioButtonForJUnit3 = new JRadioButton();
    JRadioButton radioButtonForJUnit4 = new JRadioButton();

    Mnemonics.setLocalizedText(radioButtonForJUnit3, BUNDLE.getString("LBL_JUnit3_generator"));                       //NOI18N
    Mnemonics.setLocalizedText(radioButtonForJUnit4, BUNDLE.getString("LBL_JUnit4_generator"));                       //NOI18N

    radioButtonForJUnit3.getAccessibleContext().setAccessibleDescription(BUNDLE.getString("AD_JUnit3_generator"));    //NOI18N
    radioButtonForJUnit4.getAccessibleContext().setAccessibleDescription(BUNDLE.getString("AD_JUnit4_generator"));    //NOI18N

    ButtonGroup group = new ButtonGroup();
    group.add(radioButtonForJUnit3);
    group.add(radioButtonForJUnit4);
    radioButtonForJUnit4.setSelected(true);

    JComponent msg = createMultilineLabel(BUNDLE.getString("MSG_select_junit_version")); //NOI18N
    JPanel choicePanel = new JPanel(new GridLayout(0, 1, 0, 3));
    choicePanel.add(radioButtonForJUnit3);
    choicePanel.add(radioButtonForJUnit4);

    JPanel panel = new JPanel(new BorderLayout(0, 12));
    panel.add(msg, BorderLayout.NORTH);
    panel.add(choicePanel, BorderLayout.CENTER);

    JButton button = new JButton();
    Mnemonics.setLocalizedText(button, BUNDLE.getString("LBL_Select"));     //NOI18N
    button.getAccessibleContext().setAccessibleDescription("AD_Select");    //NOI18N
    button.getAccessibleContext().setAccessibleName("AN_Select");           //NOI18N

    Object answer = DialogDisplayer.getDefault().notify(
            new DialogDescriptor(
                    wrapDialogContent(panel),
                    BUNDLE.getString("LBL_title_select_generator"),         //NOI18N
                    true,
                    new Object[] {button, NotifyDescriptor.CANCEL_OPTION},
                    button,
                    DialogDescriptor.DEFAULT_ALIGN,
                    null,
                    (ActionListener) null));

    if (answer == button) {
        if (radioButtonForJUnit3.isSelected()) {
            return JUnit.JUNIT3;
        } else {
            return JUnit.JUNIT4;
        }
    } else {
        return null;
    }
}
 
Example 16
Source File: GatewayLoginFrameHandler.java    From ib-controller with GNU General Public License v3.0 4 votes vote down vote up
private void switchToFIX(Window window) throws IBControllerException {
    JRadioButton button = SwingUtils.findRadioButton(window, "FIX CTCI");
    if (button == null) throw new IBControllerException("FIX CTCI radio button");
    
    if (! button.isSelected()) button.doClick();
}
 
Example 17
Source File: SwingUtils.java    From IBC with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Sets or clears the specified JRadioButton .
 * @param window
 * the window in which to search for the required JRadioButton 
 * @param buttonText
 * the label for the required JRadioButton 
 * @param value
 * true to set the JRadioButton ; false to clear it
 * @return
 * true if the JRadioButton  was found; otherwise false
 */
static boolean setRadioButtonSelected(Window window, String buttonText) {
    final JRadioButton rb = findRadioButton(window, buttonText);
    if (rb == null) return false;

    if (rb.isSelected()) return true;

    rb.doClick();
    return true;
}
 
Example 18
Source File: SwingUtils.java    From ib-controller with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Indicates whether the specified JRadioButton is selected.
 * @param window
 * the window in which to search for the required JRadioButton
 * @param buttonText
 * the label of the required JRadioButton
 * @return
 * true if the JRadioButton is enabled; false if there is no such JRadioButton, or it
 * is not selected
 */
static boolean isRadioButtonSelected(Window window, String buttonText) {
    final JRadioButton rb = findRadioButton(window, buttonText);
    if (rb == null) return false;

    return rb.isSelected();

}
 
Example 19
Source File: SwingUtils.java    From ib-controller with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Sets or clears the specified JRadioButton .
 * @param window
 * the window in which to search for the required JRadioButton 
 * @param buttonText
 * the label for the required JRadioButton 
 * @param value
 * true to set the JRadioButton ; false to clear it
 * @return
 * true if the JRadioButton  was found; otherwise false
 */
static boolean setRadioButtonSelected(Window window, String buttonText) {
    final JRadioButton rb = findRadioButton(window, buttonText);
    if (rb == null) return false;

    if (rb.isSelected()) return true;

    rb.doClick();
    return true;
}
 
Example 20
Source File: SwingUtils.java    From IBC with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Indicates whether the specified JRadioButton is selected.
 * @param window
 * the window in which to search for the required JRadioButton
 * @param buttonText
 * the label of the required JRadioButton
 * @return
 * true if the JRadioButton is enabled; false if there is no such JRadioButton, or it
 * is not selected
 */
static boolean isRadioButtonSelected(Window window, String buttonText) {
    final JRadioButton rb = findRadioButton(window, buttonText);
    if (rb == null) return false;

    return rb.isSelected();

}