📄 testframe.java
字号:
package test.gui;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class TestFrame {
public static void main(String[] args) {
JFrame frame = new JFrame("hello");
frame.setSize(500,200);
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
// frame.setLayout(new GridLayout(3,2));
frame.setLayout(new FlowLayout());
JButton button1 = new JButton("west");
JButton button2 = new JButton("east");
JButton button3 = new JButton("sourth");
JButton button4 = new JButton("north");
JButton button5 = new JButton("center");
frame.add(button1,BorderLayout.WEST);
frame.add(button2,BorderLayout.EAST);
frame.add(button3,BorderLayout.SOUTH);
frame.add(button4,BorderLayout.NORTH);
frame.add(button5,BorderLayout.CENTER);
System.out.println(frame.getLayout());
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -