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


Java JRadioButton.setOpaque方法代码示例

本文整理汇总了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));
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:18,代码来源:Query.java

示例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);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:46,代码来源:Query.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:bug8041561.java


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