test.java

来自「《Java2图形设计卷II:Swing》配套光盘源码」· Java 代码 · 共 32 行

JAVA
32
字号
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends JApplet {
	public Test() {
		Container contentPane = getContentPane();
		Icon icon = new ImageIcon("bulb.gif");
		JRadioButton[] radioButtons = new JRadioButton[] {
				new JRadioButton(),
				new JRadioButton(icon),
				new JRadioButton(icon, true),
				new JRadioButton("idea!"),
				new JRadioButton("idea!",true),
				new JRadioButton("idea!",icon),
				new JRadioButton("idea!",icon, true)
		};
		contentPane.setLayout(new FlowLayout());

		for(int i=0; i < radioButtons.length; ++i) {
			radioButtons[i].setBorderPainted(true);
			contentPane.add(radioButtons[i]);

			if(radioButtons[i].getIcon() != null) {
			System.out.println("setting selected icon");
				radioButtons[i].setSelectedIcon(
					new ImageIcon("bulb_bright.gif"));
			}
		}
	}
}

⌨️ 快捷键说明

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