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

📄 radiobuttons.java

📁 简单的Java Gui,用Java编辑器真接打开
💻 JAVA
字号:
//: c13:RadioButtons.java
// Using JRadioButtons.
// <applet code=RadioButtons
// width=200 height=100></applet>

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import com.bruceeckel.swing.*;

public class RadioButtons extends JApplet
{
	JTextField t = new JTextField(15);
	ButtonGroup g = new ButtonGroup();
	JRadioButton rb1 = new JRadioButton("one", false);
	JRadioButton rb2 = new JRadioButton("two", false);
	JRadioButton rb3 = new JRadioButton("three", false);
	
	ActionListener a1 = new ActionListener() 
	{
		public void actionPerformed(ActionEvent e)
		{
			t.setText("Radio button" + ((JRadioButton)e.getSource()).getText());
		}	
	};
	
	public void init()
	{
		rb1.addActionListener(a1);
		rb2.addActionListener(a1);
		rb3.addActionListener(a1);
		
		g.add(rb1);
		g.add(rb2);
		g.add(rb3);
		
		t.setEditable(false);
		Container cp = getContentPane();
		cp.setLayout(new FlowLayout());
		cp.add(t);
		cp.add(rb1);
		cp.add(rb2);
		cp.add(rb3);
	}
	
	public static void main(String[] args)
	{
		RadioButtons applet = new RadioButtons();
		JFrame frame = new JFrame("RadioButtons");
		frame.getContentPane().add(applet);
		frame.setSize(375, 125);
		applet.init();
		applet.start();
		frame.setVisible(true);
	}
}///:~

⌨️ 快捷键说明

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