📄 swingdemo.java
字号:
package chapter11;
import java.awt.GridLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
public class SwingDemo {
public static void main(String[] args) {
JFrame jfm = new JFrame("Swing GUI");
jfm.setLayout(new GridLayout(5, 2));
jfm.add(new JButton("JButton"));
jfm.add(new JLabel("JLabel"));
jfm.add(new JCheckBox("JCheckBox"));
jfm.add(new JCheckBox("JCheckBox2"));
jfm.add(new JCheckBox("JCheckBox3"));
jfm.add(new JTextArea("JTextArea"));
ButtonGroup bg = new ButtonGroup();
JRadioButton jrb1 = new JRadioButton("JRadioButton1");
JRadioButton jrb2 = new JRadioButton("JRadioButton2");
JRadioButton jrb3 = new JRadioButton("JRadioButton3");
bg.add(jrb1);
bg.add(jrb2);
bg.add(jrb3);
jfm.add(jrb1);
jfm.add(jrb2);
jfm.add(jrb3);
jfm.pack();
jfm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jfm.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -