📄 checkbox.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CheckBox extends JFrame{
private Label field;
private JRadioButton simpButton,middButton,hardButton;
private ButtonGroup radioGroup;
private int numOfMine;
private int colum;
private int row;
public CheckBox()
{
super("RadioButton");
Container container=getContentPane();
container.setLayout(new FlowLayout());
field=new Label("Choose the level");
container.add(field);
simpButton=new JRadioButton("初级",false);
container.add(simpButton);
middButton=new JRadioButton("中级",false);
container.add(middButton);
hardButton=new JRadioButton("高级",false);
container.add(hardButton);
radioGroup =new ButtonGroup();
radioGroup.add(simpButton);
radioGroup.add(middButton);
radioGroup.add(hardButton);
simpButton.addItemListener(new RadioButtonHandle());
middButton.addItemListener(new RadioButtonHandle());
hardButton.addItemListener(new RadioButtonHandle());
setSize(300,100);
setLocationRelativeTo(getParent());
setVisible(true);
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
public int GetNum()
{
return numOfMine;
}
public int GetRow()
{
return row;
}
public int GetCol()
{
return colum;
}
private class RadioButtonHandle implements ItemListener
{
public RadioButtonHandle()
{
}
public void itemStateChanged(ItemEvent event)
{
if((JRadioButton)event.getItem()==simpButton)
{
numOfMine=10;
row=10;
colum=10;
}
else if((JRadioButton)event.getItem()==middButton)
{
numOfMine=40;
row=16;
colum=16;
}
else if((JRadioButton)event.getItem()==hardButton)
{
numOfMine=99;
row=16;
colum=30;
}
else
{
numOfMine=16;
row=10;
colum=10;
}
MineGame game=new MineGame(numOfMine,row,colum);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -