// 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. [PY3]——环境配置(1)——pyenv | pip | ipython | jupyter(含安装pyenv环境shell脚本)

    1.关于pyenv (1)pyenv是一个开源的.shell脚本编写的工具:Simple Python version management (2)为什么使用pyenv:当多个项目同时在开发与维护时, ...

  2. docker使用示例

    本文使用docker容器运行wordpress博客,采用了三种方法来演示,docker的使用 自建wordpress容器 采用官方的wordpress容器 采用docker compose容器管理工具 ...

  3. 每日英语:Six Ways to Modernize Your Car

    AS AUTO MAKERS ADD far-out features to the latest cars at warp speed--everything from futuristic hea ...

  4. 【Redis】Redis的基本安装及使用、Jedis的基本使用、spring-data-redis的集成、主从模式、哨兵模式

    在Linux上安装Redis Redis的安装很简单.基本上是下载.解压.运行安装脚本.我用的Redis版本是3.2.1. [nicchagil@localhost app]$ wget -q htt ...

  5. 笔记本貌似好了(HP 450 卡)

    2013年9月份在苏宁上 买了个HP450,配置应该算还勉强,i5, 4G, 照理说一般LOL,DOTA,应该还可以.但是经常在打完一盘后,切出来,卡的要命,一直没有解决,昨天晚上虚拟机切出来,更是, ...

  6. 使用PyHive操作Hive

    使用PyHive操作Hive 废话 搜了一下,看到了StackOverFlow的回答,试了一下前两个方案,感觉第二个更简洁,这里记录一下,更详细的见参考. 安装依赖 pip install sasl ...

  7. openfire维持在线状态,监听消息

    public static void testLoginStatus()throws XMPPException,InterruptedException { AccountManager accou ...

  8. Airlaunch 快捷设置代码分享

    Airlaunch 快捷设置代码分享设置:prefs:root=SETTING蜂窝网络:prefs:root=MOBILE_DATA_SETTINGS_IDWIFI:prefs:root=WIFI定位 ...

  9. django后台显示图片 而不是图片地址

    修改admin代码 class Ad_CampaingAdmin(admin.ModelAdmin): list_display = ("content","previe ...

  10. ubuntu 16.04如何生成ssh key以及如何查看ssh key

    检查本地是否有SSH Key存在 在终端输入 ls -al ~/.ssh 如果输出的是: No such file or directory 那就没有ssh key 如果有就会出现这样: 生成新的SS ...