JRadioButton的用法

JRadioButton用法
 

import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.FlowLayout;


public class JRadioButtonDemo
{
 public static void main(String[] args)
 {
 
  JRadioButton red, white, cyan;
  red = new JRadioButton ("red");
  white = new JRadioButton ("white");
  cyan = new JRadioButton ("cyan");
 
  ButtonGroup group = new ButtonGroup ();
  group.add (red);
  group.add (white);
  group.add (cyan);
 
  JPanel panel = new JPanel (new FlowLayout (FlowLayout.CENTER, 1, 0));
  panel.setBackground (Color.white);
  panel.setPreferredSize (new Dimension (200,50));
  panel.add (red);
  panel.add (white);
  panel.add (cyan);
 
  JFrame frame = new JFrame("JRadioButtonDemo");
  frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
 
  frame.setContentPane(panel);
  frame.pack();
  frame.show();
 }
}


 
 

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试