代码如下:

使用JRadioButton 示例
JRadioButton useCache=new JRadioButton("Use cache");// 初始化单选框
useCache.setFont(new Font("Arial",Font.PLAIN,16));// 设置字体
JRadioButton noUseCache=new JRadioButton("No cache used");
noUseCache.setFont(new Font("Arial",Font.PLAIN,16));

ButtonGroup bg=new ButtonGroup();// 初始化按钮组
bg.add(useCache);// 加入按钮组
bg.add(noUseCache);// 加入按钮组

noUseCache.setSelected(true);// 选择

useCache.isSelected();// 获取radiobutton的选择状态
使用JRadioButton 示例

效果如下:

使用JRadioButton 示例













本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/xiandedanteng/p/3699205.html,如需转载请自行联系原作者






相关文章:

  • 2021-04-24
  • 2021-05-30
  • 2021-06-03
  • 2022-01-22
  • 2021-10-09
  • 2022-01-03
  • 2021-12-26
  • 2021-06-22
猜你喜欢
  • 2021-09-05
  • 2022-12-23
  • 2021-12-05
  • 2021-12-15
  • 2021-11-09
相关资源
相似解决方案