本文整理汇总了Java中javax.swing.JRadioButton.setOpaque方法的典型用法代码示例。如果您正苦于以下问题:Java JRadioButton.setOpaque方法的具体用法?Java JRadioButton.setOpaque怎么用?Java JRadioButton.setOpaque使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JRadioButton
的用法示例。
在下文中一共展示了JRadioButton.setOpaque方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: addRadioButtons
import javax.swing.JRadioButton; //导入方法依赖的package包/类
/** Create a bank of radio buttons. A radio button provides a list of
* choices, only one of which may be chosen at a time.
* @param name The name used to identify the entry (when calling get).
* @param label The label to attach to the entry.
* @param values The list of possible choices.
* @param defaultValue Default value.
*/
public void addRadioButtons(
String name,
String label,
String[] values,
String defaultValue) {
JLabel lbl = new JLabel(label + ": ");
lbl.setBackground(_background);
FlowLayout flow = new FlowLayout();
flow.setAlignment(FlowLayout.LEFT);
// This must be a JPanel, not a Panel, or the scroll bars won't work.
JPanel buttonPanel = new JPanel(flow);
ButtonGroup group = new ButtonGroup();
QueryActionListener listener = new QueryActionListener(name);
// Regrettably, ButtonGroup provides no method to find out
// which button is selected, so we have to go through a
// song and dance here...
JRadioButton[] buttons = new JRadioButton[values.length];
for (int i = 0; i < values.length; i++) {
JRadioButton checkbox = new JRadioButton(values[i]);
buttons[i] = checkbox;
checkbox.setBackground(_background);
// The following (essentially) undocumented method does nothing...
// checkbox.setContentAreaFilled(true);
checkbox.setOpaque(false);
if (values[i].equals(defaultValue)) {
checkbox.setSelected(true);
}
group.add(checkbox);
buttonPanel.add(checkbox);
// Add the listener last so that there is no notification
// of the first value.
checkbox.addActionListener(listener);
}
_addPair(name, lbl, buttonPanel, buttons);
}
示例3: createAndShowGUI
import javax.swing.JRadioButton; //导入方法依赖的package包/类
private static void createAndShowGUI() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBackground(Color.BLUE);
radioButton = new JRadioButton();
radioButton.setOpaque(false);
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.add(radioButton);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}