jrbutton.java

来自「详细讲解了java的基础知识」· Java 代码 · 共 48 行

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

public class JRButton extends JApplet
{
	
	public void init()
	{		
		Container contentPane = getContentPane();
		JPanel jpane1=new JPanel();		
		jpane1.setLayout(new FlowLayout());
		contentPane.add(jpane1,BorderLayout.CENTER);
		
		Icon icon1 = new ImageIcon("disk1.gif");
		Icon icon2 = new ImageIcon("disk2.gif");
		Icon icon3= new ImageIcon("disk3.gif");
		Icon icon4 = new ImageIcon("disk4.gif");
		
		JRadioButton[] radioButtons = new JRadioButton[] {
			new JRadioButton(),
			new JRadioButton(icon1),
			new JRadioButton(icon2, true),
			new JRadioButton("文字"),
			new JRadioButton("文字",true),
			new JRadioButton("文字",icon3),
			new JRadioButton("文字",icon4, false)
		};		
		
			

		for(int i=0; i < radioButtons.length; ++i) {
			radioButtons[i].setBorderPainted(true);
			jpane1.add(radioButtons[i]);
			
		}
		resize(500,150);
	}

	
}




⌨️ 快捷键说明

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