当前位置: 首页>>代码示例>>Java>>正文


Java JRadioButton.isSelected方法代码示例

本文整理汇总了Java中javax.swing.JRadioButton.isSelected方法的典型用法代码示例。如果您正苦于以下问题:Java JRadioButton.isSelected方法的具体用法?Java JRadioButton.isSelected怎么用?Java JRadioButton.isSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JRadioButton的用法示例。


在下文中一共展示了JRadioButton.isSelected方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getType

import javax.swing.JRadioButton; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Reset.java

示例2: isOptionSelected

import javax.swing.JRadioButton; //导入方法依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:SelectionDialog.java

示例3: actionPerformed

import javax.swing.JRadioButton; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	for (JRadioButton radio : radios) {
		if (radio != button && radio.isSelected()) {
			radio.setSelected(false);
		} else if (radio == button && !radio.isSelected()) {
			radio.setSelected(true);
		}
	}
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:11,代码来源:RadioGroup.java

示例4: actionPerformed

import javax.swing.JRadioButton; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	for (JRadioButton comp : compToTag.keySet()) {
		if (comp != btn && comp.isSelected()) {
			comp.setSelected(false);
		} else if (comp == btn) {
			setValue(compToTag.get(comp));
		}
	}
}
 
开发者ID:Col-E,项目名称:Recaf,代码行数:11,代码来源:TagTypeSwitchPanel.java

示例5: save

import javax.swing.JRadioButton; //导入方法依赖的package包/类
public void save() {
	JPanel panel = new JPanel( new GridLayout(0,1) );
	JLabel label = new JLabel("Save/Download");
	label.setForeground(Color.black);
	panel.add( label );
	ButtonGroup group = new ButtonGroup();
	JRadioButton jpeg = new JRadioButton("JPEG image");
	group.add(jpeg);
	panel.add( jpeg);
	JRadioButton segy = new JRadioButton("SEGY file");
	group.add(segy);
	panel.add( segy);
	nav = new JRadioButton("CDP Navigation");
	group.add(nav);
	panel.add( nav);
	JRadioButton history = new JRadioButton("processing history");
	group.add(history);
	panel.add( history);
	jpeg.setSelected(true);
	int ok = JOptionPane.showOptionDialog( image.getTopLevelAncestor(),
		panel,
		"cruise "+ image.getCruiseID() +", line "+ image.getID(),
		JOptionPane.OK_CANCEL_OPTION,
		JOptionPane.PLAIN_MESSAGE,
		null, null, null);
	if( ok== JOptionPane.CANCEL_OPTION) return;
	if( nav.isSelected() ||
		segy.isSelected()  
		|| history.isSelected() )saveSegy(history.isSelected());
	else saveJPEG();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:32,代码来源:MCSSave.java

示例6: save

import javax.swing.JRadioButton; //导入方法依赖的package包/类
void save(){
	JPanel savePanel = new JPanel( new BorderLayout() );
	savePanel.setBorder(BorderFactory.createEmptyBorder( 0, 5, 0, 5));

	JPanel savePrompt = new JPanel(new GridLayout(0, 1));
	JRadioButton saveTableRB = new JRadioButton("Save as ASCII Table");
	JRadioButton saveJPGProfileRB = new JRadioButton("Save Profile as JPG");
	JRadioButton savePNGProfileRB = new JRadioButton("Save Profile as PNG");
	saveJPGProfileRB.setEnabled(tabs[2].isSelected());
	savePNGProfileRB.setEnabled(tabs[2].isSelected());
	ButtonGroup saveGroup = new ButtonGroup();
	saveGroup.add(saveTableRB);
	saveGroup.add(saveJPGProfileRB);
	saveGroup.add(savePNGProfileRB);
	saveTableRB.setSelected(true);
	savePrompt.add(saveTableRB);
	savePrompt.add(saveJPGProfileRB);
	savePrompt.add(savePNGProfileRB);
	savePanel.add(savePrompt, BorderLayout.CENTER);
	
	int s = JOptionPane.showConfirmDialog(map, savePanel, "Save Options", JOptionPane.OK_CANCEL_OPTION);
	if(s == 2) {
		return;
	}
	if (saveTableRB.isSelected()) {
		saveTable();
		return;
	}
	String fmt = "jpg";
	if (savePNGProfileRB.isSelected()) {
		fmt = "png";
	}
	saveProfile(fmt);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:35,代码来源:Digitizer.java

示例7: getStringValue

import javax.swing.JRadioButton; //导入方法依赖的package包/类
/** 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());
    }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:69,代码来源:Query.java

示例8: sessionUI

import javax.swing.JRadioButton; //导入方法依赖的package包/类
protected void sessionUI() {
	setSessionID();
	//textfields needed for UI
	JTextField sessionIDText = new JTextField(getSessionID());
	sessionIDText.setEditable(false);
	JTextArea sessionDescripText = new JTextArea(4,5);
	sessionDescripText.setLineWrap(true);
	JScrollPane scrollPane = new JScrollPane(sessionDescripText);
       
	//Radio Button List
	JRadioButton newFeature = new JRadioButton("New Feature");
	JRadioButton bugFix = new JRadioButton("Bug Fix");
	JRadioButton refactoring = new JRadioButton("Refactoring");
	JRadioButton genComp = new JRadioButton("General Comprehension");
	JRadioButton other = new JRadioButton("Other");
	
	//Group the buttons
	ButtonGroup radioList = new ButtonGroup();
	radioList.add(newFeature);
	radioList.add(bugFix);
	radioList.add(refactoring);
	radioList.add(genComp);
	radioList.add(other);
	
	//Add to a JPanel
	JPanel radioPanel = new JPanel(new GridLayout(0, 1));
	radioPanel.add(newFeature);
	radioPanel.add(bugFix);
	radioPanel.add(refactoring);
	radioPanel.add(genComp);
	radioPanel.add(other);
	
	//Add everything to main JPanel
	JPanel sessionPanel = new JPanel(); //main panel
	sessionPanel.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.NONE;
	c.anchor = GridBagConstraints.NORTHWEST;
	
	c.gridx = 0;
	c.gridy = 0;
	sessionPanel.add(new JLabel("Generated Session ID:"),c);
	c.gridx++;
	sessionPanel.add(sessionIDText,c);
	c.gridx = 0;
	c.gridy++;
	sessionPanel.add(new JLabel("Session Purpose (select one):"),c);
	c.gridx++;
	sessionPanel.add(radioPanel,c);
	c.gridx = 0;
	c.gridy++;
	sessionPanel.add(new JLabel("Enter the Session Description:"),c);
	c.gridx++;
	c.fill = GridBagConstraints.HORIZONTAL;
	sessionPanel.add(scrollPane,c);
	
	final int selection = JOptionPane.showConfirmDialog(null, sessionPanel, 
			"Enter the Current Session Info.",
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
	if (selection == JOptionPane.OK_OPTION) {
		sessionDescrip = sessionDescripText.getText();
		if (newFeature.isSelected()) {
			sessionPurpose = newFeature.getText();
		} else if (bugFix.isSelected()) {
			sessionPurpose = bugFix.getText();
		} else if (refactoring.isSelected()) {
			sessionPurpose = refactoring.getText();
		} else if (genComp.isSelected()) {
			sessionPurpose = genComp.getText();
		} else if (other.isSelected()) {
			sessionPurpose = other.getText();
		} else {
			sessionPurpose = new String();
			System.out.println("Warning! "
					+ "Your Session Purpose has not been selected.");
		}
		hasSessionInfo = true;
	}  
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:80,代码来源:SessionInfoHandler.java


注:本文中的javax.swing.JRadioButton.isSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。