本文整理汇总了Java中javax.swing.JRadioButton.addItemListener方法的典型用法代码示例。如果您正苦于以下问题:Java JRadioButton.addItemListener方法的具体用法?Java JRadioButton.addItemListener怎么用?Java JRadioButton.addItemListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JRadioButton
的用法示例。
在下文中一共展示了JRadioButton.addItemListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _loadChoices
import javax.swing.JRadioButton; //导入方法依赖的package包/类
@Override
protected void _loadChoices(Iterable<CHOICE_TYPE> choiceList)
{
for( CHOICE_TYPE choice : choiceList )
{
final JRadioButton button = new JRadioButton(getChoiceTitle(choice));
button.addItemListener(buttonListener);
buttonGroup.add(button);
final DynamicChoicePanel<STATE_TYPE> choicePanel = getChoicePanel(choice);
choicePanel.setId(getChoiceId(choice));
add(button);
add(choicePanel, "gap indent, grow");
choices.put(button, choicePanel);
}
}
示例2: addCheckBox
import javax.swing.JRadioButton; //导入方法依赖的package包/类
/** Create an on-off check box.
* @param name The name used to identify the entry (when calling get).
* @param label The label to attach to the entry.
* @param defaultValue The default value (true for on).
*/
public void addCheckBox(String name, String label, boolean defaultValue) {
JLabel lbl = new JLabel(label + ": ");
lbl.setBackground(_background);
JRadioButton checkbox = new JRadioButton();
checkbox.setBackground(_background);
checkbox.setOpaque(false);
checkbox.setSelected(defaultValue);
_addPair(name, lbl, checkbox, checkbox);
// Add the listener last so that there is no notification
// of the first value.
checkbox.addItemListener(new QueryItemListener(name));
}
示例3: createButton
import javax.swing.JRadioButton; //导入方法依赖的package包/类
private JRadioButton createButton(JPanel panel, ButtonGroup group, String textKey)
{
JRadioButton button = new JRadioButton(CurrentLocale.get(textKey));
button.addItemListener(this);
group.add(button);
panel.add(button);
return button;
}
示例4: getZoomSection
import javax.swing.JRadioButton; //导入方法依赖的package包/类
private JPanel getZoomSection() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
ButtonGroup group = new ButtonGroup();
double zoom = Config.getDefault().getZoom();
c.anchor = GridBagConstraints.WEST;
//out("GET ZOOM: " + zoom);
// (o) Fit width to
c.gridy++;
c.insets = new Insets(LARGE_SIZE, 0, 0, 0);
JRadioButton buttonWidth = createRadioButton(i18n("LBL_Fit_Width_to"), i18n("TLT_Fit_Width_to")); // NOI18N
buttonWidth.addItemListener(createItemListener(true, false, false));
panel.add(buttonWidth, c);
group.add(buttonWidth);
// [width]
c.insets = new Insets(LARGE_SIZE, LARGE_SIZE, TINY_SIZE, 0);
myZoomWidth = new JTextField(getString(Percent.getZoomWidth(zoom, 1)));
setWidth(myZoomWidth, TEXT_WIDTH);
panel.add(myZoomWidth, c);
// page(s)
c.weightx = 1.0;
panel.add(createLabel(i18n("LBL_Pages")), c); // NOI18N
// (o) Zoom to
c.weightx = 0.0;
c.insets = new Insets(LARGE_SIZE, 0, 0, 0);
JRadioButton buttonFactor = createRadioButton(i18n("LBL_Zoom_to"), i18n("TLT_Zoom_to")); // NOI18N
buttonFactor.addItemListener(createItemListener(false, false, true));
panel.add(buttonFactor, c);
group.add(buttonFactor);
// [zoom]
c.insets = new Insets(LARGE_SIZE, LARGE_SIZE, TINY_SIZE, 0);
//out("ZOOM:" + Percent.getZoomFactor(zoom, 1.0));
myZoomFactor = new Percent(this, Percent.getZoomFactor(zoom, 1.0), PERCENTS, 0, null, i18n("TLT_Print_Zoom")); // NOI18N
panel.add(myZoomFactor, c);
// (o) Fit height to
c.gridy++;
c.weightx = 0.0;
c.insets = new Insets(LARGE_SIZE, 0, 0, 0);
JRadioButton buttonHeight = createRadioButton(i18n("LBL_Fit_Height_to"), i18n("TLT_Fit_Height_to")); // NOI18N
buttonHeight.addItemListener(createItemListener(false, true, false));
panel.add(buttonHeight, c);
group.add(buttonHeight);
// [height]
c.insets = new Insets(LARGE_SIZE, LARGE_SIZE, TINY_SIZE, 0);
myZoomHeight = new JTextField(getString(Percent.getZoomHeight(zoom, 1)));
setWidth(myZoomHeight, TEXT_WIDTH);
panel.add(myZoomHeight, c);
// page(s)
panel.add(createLabel(i18n("LBL_Pages")), c); // NOI18N
// (o) Fit to page
c.weightx = 0.0;
c.insets = new Insets(LARGE_SIZE, 0, 0, 0);
myFitToPage = createRadioButton(i18n("LBL_Fit_to_Page"), i18n("TLT_Fit_to_Page")); // NOI18N
myFitToPage.addItemListener(createItemListener(false, false, false));
panel.add(myFitToPage, c);
group.add(myFitToPage);
buttonFactor.setSelected(Percent.isZoomFactor(zoom));
buttonWidth.setSelected(Percent.isZoomWidth(zoom));
buttonHeight.setSelected(Percent.isZoomHeight(zoom));
myFitToPage.setSelected(Percent.isZoomPage(zoom));
// panel.setBorder(new javax.swing.border.LineBorder(java.awt.Color.green));
return panel;
}
示例5: RadioButtonFrame
import javax.swing.JRadioButton; //导入方法依赖的package包/类
public RadioButtonFrame()
{
super("RadioButton Test");
setLayout(new FlowLayout());
textField = new JTextField("Watch the font style change", 25);
add(textField); // add textField to JFrame
// create radio buttons
plainJRadioButton = new JRadioButton("Plain", true);
boldJRadioButton = new JRadioButton("Bold", false);
italicJRadioButton = new JRadioButton("Italic", false);
boldItalicJRadioButton = new JRadioButton("Bold/Italic", false);
add(plainJRadioButton); // add plain button to JFrame
add(boldJRadioButton); // add bold button to JFrame
add(italicJRadioButton); // add italic button to JFrame
add(boldItalicJRadioButton); // add bold and italic button
// create logical relationship between JRadioButtons
radioGroup = new ButtonGroup(); // create ButtonGroup
radioGroup.add(plainJRadioButton); // add plain to group
radioGroup.add(boldJRadioButton); // add bold to group
radioGroup.add(italicJRadioButton); // add italic to group
radioGroup.add(boldItalicJRadioButton); // add bold and italic
// create font objects
plainFont = new Font("Serif", Font.PLAIN, 14);
boldFont = new Font("Serif", Font.BOLD, 14);
italicFont = new Font("Serif", Font.ITALIC, 14);
boldItalicFont = new Font("Serif", Font.BOLD + Font.ITALIC, 14);
textField.setFont(plainFont);
// register events for JRadioButtons
plainJRadioButton.addItemListener(
new RadioButtonHandler(plainFont));
boldJRadioButton.addItemListener(
new RadioButtonHandler(boldFont));
italicJRadioButton.addItemListener(
new RadioButtonHandler(italicFont));
boldItalicJRadioButton.addItemListener(
new RadioButtonHandler(boldItalicFont));
}