本文整理汇总了Java中javax.swing.JRadioButtonMenuItem.isSelected方法的典型用法代码示例。如果您正苦于以下问题:Java JRadioButtonMenuItem.isSelected方法的具体用法?Java JRadioButtonMenuItem.isSelected怎么用?Java JRadioButtonMenuItem.isSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JRadioButtonMenuItem
的用法示例。
在下文中一共展示了JRadioButtonMenuItem.isSelected方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: persist
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
public static void persist(JMenu menu, String tag) {
int rb = 0;
boolean inRb = false;
for (int j = 0; j < menu.getItemCount(); ++j) {
if (menu.getItem(j) instanceof JRadioButtonMenuItem) {
if (!inRb) {
inRb = true;
++rb;
}
JRadioButtonMenuItem rbItem = (JRadioButtonMenuItem)menu.getItem(j);
if (rbItem.isSelected()) {
Persist.set("#." + tag + menu.getText() + "." + rb, Persist.toTag("#." + rb + "." + rbItem.getActionCommand()));
}
} else {
inRb = false;
if (menu.getItem(j) instanceof JCheckBoxMenuItem) {
JCheckBoxMenuItem cbItem = (JCheckBoxMenuItem)menu.getItem(j);
Persist.set("#." + tag + menu.getText() + ' ' + cbItem.getText(), cbItem.getState() ? "true" : "false");
} else
if (menu.getItem(j) instanceof JMenu) {
persist((JMenu)menu.getItem(j), tag);
}
}
}
}
示例2: getSelectedLanguage
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
/***************************************Source compilation****************************************************/
protected Language getSelectedLanguage() {
for (JRadioButtonMenuItem rbmi : main.rbmiSelection.keySet()) {
if (rbmi.isSelected()) {
return main.rbmiSelection.get(rbmi);
}
}
throw new IllegalStateException("Undefined state. No language selected.");
}
示例3: paintIcon
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
/**
* Paints the icon.
*
* @param c the component.
* @param g the graphics device.
* @param x the x-coordinate.
* @param y the y-coordinate.
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
Color savedColor = g.getColor();
JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
g.setColor(MetalLookAndFeel.getBlack());
g.drawLine(x + 2, y, x + 6, y);
g.drawLine(x + 7, y + 1, x + 7, y + 1);
g.drawLine(x + 8, y + 2, x + 8, y + 6);
g.drawLine(x + 7, y + 7, x + 7, y + 7);
g.drawLine(x + 2, y + 8, x + 6, y + 8);
g.drawLine(x + 1, y + 7, x + 1, y + 7);
g.drawLine(x, y + 2, x, y + 6);
g.drawLine(x + 1, y + 1, x + 1, y + 1);
if (item.isSelected())
{
g.drawLine(x + 3, y + 2, x + 5, y + 2);
g.fillRect(x + 2, y + 3, 5, 3);
g.drawLine(x + 3, y + 6, x + 5, y + 6);
}
// highlight
g.setColor(MetalLookAndFeel.getControlHighlight());
g.drawLine(x + 3, y + 1, x + 6, y + 1);
g.drawLine(x + 8, y + 1, x + 8, y + 1);
g.drawLine(x + 9, y + 2, x + 9, y + 7);
g.drawLine(x + 8, y + 8, x + 8, y + 8);
g.drawLine(x + 2, y + 9, x + 7, y + 9);
g.drawLine(x + 1, y + 8, x + 1, y + 8);
g.drawLine(x + 1, y + 3, x + 1, y + 6);
g.drawLine(x + 2, y + 2, x + 2, y + 2);
g.setColor(savedColor);
}
示例4: paintIcon
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
/**
* Paints the icon.
*
* @param c the component.
* @param g the graphics device.
* @param x the x-coordinate.
* @param y the y-coordinate.
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
Color savedColor = g.getColor();
JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
g.setColor(MetalLookAndFeel.getBlack());
g.drawLine(x + 2, y, x + 6, y);
g.drawLine(x + 7, y + 1, x + 7, y + 1);
g.drawLine(x + 8, y + 2, x + 8, y + 6);
g.drawLine(x + 7, y + 7, x + 7, y + 7);
g.drawLine(x + 2, y + 8, x + 6, y + 8);
g.drawLine(x + 1, y + 7, x + 1, y + 7);
g.drawLine(x, y + 2, x, y + 6);
g.drawLine(x + 1, y + 1, x + 1, y + 1);
if (item.isSelected())
{
g.drawLine(x + 3, y + 2, x + 5, y + 2);
g.fillRect(x + 2, y + 3, 5, 3);
g.drawLine(x + 3, y + 6, x + 5, y + 6);
}
// highlight
g.setColor(MetalLookAndFeel.getControlHighlight());
g.drawLine(x + 3, y + 1, x + 6, y + 1);
g.drawLine(x + 8, y + 1, x + 8, y + 1);
g.drawLine(x + 9, y + 2, x + 9, y + 7);
g.drawLine(x + 8, y + 8, x + 8, y + 8);
g.drawLine(x + 2, y + 9, x + 7, y + 9);
g.drawLine(x + 1, y + 8, x + 1, y + 8);
g.drawLine(x + 1, y + 3, x + 1, y + 6);
g.drawLine(x + 2, y + 2, x + 2, y + 2);
g.setColor(savedColor);
}
示例5: getFromDropDown
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
private String getFromDropDown(JMenu menu) {
Component[] modes = menu.getMenuComponents();
String selection = "";
for (Component mode : modes) {
JRadioButtonMenuItem modeButton = (JRadioButtonMenuItem) mode;
if (modeButton.isSelected()) {
selection = modeButton.getText();
//System.out.println(selection);
return selection;
}
}
return selection;
}
示例6: buildSorter
import javax.swing.JRadioButtonMenuItem; //导入方法依赖的package包/类
Comparator<? super Drawable> buildSorter()
{
Comparator<? super Drawable> sorter = null;
for (int i = 0; i < sortCriteria.length; ++i)
{
JRadioButtonMenuItem criteria = sortCriteria[i];
if (criteria.isSelected())
sorter = sorters.get(i);
}
return sorter != null && reverseSortOrder.isSelected() ? sorter.reversed() : sorter;
}