// Create an action for each radio button
Action action1 = new AbstractAction("RadioButton Label1") {
// This method is called whenever the radio button is pressed,
// even if it is already selected; this method is not called
// if the radio button was selected programmatically
public void actionPerformed(ActionEvent evt) {
// Perform action
}
};
Action action2 = new AbstractAction("RadioButton Label2") {
// See above
public void actionPerformed(ActionEvent evt) {
// Perform action
}
}; // Create the radio buttons using the actions
JRadioButton b1 = new JRadioButton(action1);
JRadioButton b2 = new JRadioButton(action2); // Associate the two buttons with a button group
ButtonGroup group = new ButtonGroup();
group.add(b1);
group.add(b2); // Neither radio button is selected; to select a radio button,
// see e769 在按钮组中选择一个单选按钮
Related Examples

e768. 创建单选按钮的更多相关文章

  1. e769. 在按钮组中选择一个单选按钮

    // To create a radio button and button group, // see e768 创建单选按钮 // Select the radio button; the cur ...

  2. MFC 单选按钮组向导添加和动态创建

    单选按钮组的动态生成 单选按钮也属于CButton类,但由于单选按钮总是成组使用的,所以它在制作和使用上与普通按钮有一定区别. 假设有三个单选按钮组成一组,初始时,第一个单选按钮处于选中状态. 我们先 ...

  3. Chapter 4. Button, Checkbutton, and Radiobutton Widgets 按钮,复选按钮,单选按钮

    Chapter 4. Button, Checkbutton, and Radiobutton Widgets   按钮,复选按钮,单选按钮 几乎所有的Perl/Tk 应用使用按钮以这样或者那样的方式 ...

  4. MFC 动态创建控件

    动态控件是指在需要时由Create()创建的控件,这与预先在对话框中放置的控件是不同的.   一.创建动态控件:   为了对照,我们先来看一下静态控件的创建.   放置静态控件时必须先建立一个容器,一 ...

  5. Java 创建、填充PDF表单域

    表单域,可以按用途分为多种不同的类型,常见的有文本框.多行文本框.密码框.隐藏域.复选框.单选框和下拉选择框等,目的是用于采集用户的输入或选择的数据.下面的示例中,将分享通过Java编程在PDF中添加 ...

  6. matlab中uicontrol创建用户界面控件

    来源:https://ww2.mathworks.cn/help/matlab/ref/uicontrol.html?searchHighlight=uicontrol&s_tid=doc_s ...

  7. 【javascript学习——《javascript高级程序设计》笔记】DOM操作

    DOM(文档对象模型)是针对HTML和XML文档的一个API(应用程序编程接口).DOM描绘了一个层次节点树,允许开发人员添加.移除和修改. 1.节点层次 <html> <head& ...

  8. ie不兼容的几个js问题及解决办法

    1.table问题 在动态新增tr或者td时,createElement()一般用appendChild();都不生效,解决办法是用新增tbody,如 var table=document.creat ...

  9. [HTML/HTML5]9 使用表单

    9.1  创建基本表单 表单都具有相同的基础结构.即它都包含表单的的开始标记<form>和结束标记</form>.<input>控件和处理表单的方法.form元素包 ...

随机推荐

  1. shutil 高级文件操作

    High-level file operations  高级的文件操作模块,官网:https://docs.python.org/2/library/shutil.html# os模块提供了对目录或者 ...

  2. 每日英语:China Destroys Six Tons of Confiscated Ivory

    BEIJING—Chinese government officials destroyed more than six tons of ivory that had been illegally s ...

  3. 【Android】Sensor框架HAL层解读

    Android sensor构建 Android4.1 系统内置对传感器的支持达13种,他们分别是:加速度传感器(accelerometer).磁力传感器(magnetic field).方向传感器( ...

  4. ES6里新添加了两个很好用的东西,set和Array.from。

    set是一种新的数据结构,它可以接收一个数组或者是类数组对象,自动去重其中的重复项目. 在这我们可以看见,重复的项目已经被去掉了,包括NaN.正常情况下,NaN === NaN 返回的是false,但 ...

  5. django模型创建

    定义模型 模型,属性,表,字段之间的关系 一个模型类在数据库中对应一张表,在模型类中定义的属性,对应该模型对照表中的一个字段 定义属性:见下文 创建模型类 元选项 在模型类中定义Meta类,用于设置元 ...

  6. mac下java环境变量配置

    发现一个坑:最近发现有同事按照本文方式配置jdk环境变量一直不成功,后来发现他是使用了“Oh-My-Zsh”,配置文件的路径不是/etc/profile或~/.bash_profile,它有自己的配置 ...

  7. 记录 am335x 因为 pinmux 配置不对导致 不断的原因

    其实很简单,是因为 中断不仅仅需要 gpio 的 input 属性, 还需要 pull_up 的数据 {"gpmc_ad11.gpio0_27", OMAP_MUX_MODE7 | ...

  8. wifi 模块RTL8188以及mt7601u 移植测试

    kernel version:4.4.12 kernel make menuconfig // make menuconfig [*] Networking support ---> Netwo ...

  9. [进程]kill 9和15,以及pkill, killall

    转自:https://www.cnblogs.com/liuhouhou/p/5400540.html 大家对kill -9 肯定非常熟悉,在工作中也经常用到.特别是你去重启tomcat时.可是多半看 ...

  10. PHP——大话PHP设计模式——魔术方法