⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showjradiobutton.java

📁 初学的好东西值得一看看欢迎下载观看使用
💻 JAVA
字号:
import javax.swing.JFrame;
import java.awt.FlowLayout;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
class ShowJRadioButton extends JFrame implements ActionListener{
	FlowLayout flowLayout1=new FlowLayout();
	JRadioButton jRadioButton1=new JRadioButton("教师",true);
	JRadioButton jRadioButton2=new JRadioButton();
	ButtonGroup buttonGroup1=new ButtonGroup();
	JButton jButton1=new JButton("确定");
	ShowJRadioButton(){
		super("单选按钮示例");
		setSize(200,150);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		jRadioButton2.setText("学生");
		this.getContentPane().setLayout(flowLayout1);
		this.getContentPane().add(jRadioButton1);
		this.getContentPane().add(jRadioButton2);
		this.getContentPane().add(jButton1);
		buttonGroup1.add(jRadioButton1);
		buttonGroup1.add(jRadioButton2);
		jButton1.addActionListener(this);
		show();
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==jButton1){
			if(jRadioButton1.isSelected()) System.out.println("选择了教师单选按钮");
			else System.out.println("选择了学生单选按钮");
		}
	}
	public static void main(String[] args){
		//try{
		//	UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		//}catch(Exception e){}

		ShowJRadioButton showJRadioButton1=new ShowJRadioButton();
	}
}

		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -