📄 boxlayout2.java
字号:
import java.awt.*;
import javax.swing.*;
public class BoxLayout2 extends JApplet {
JButton button1 = new JButton("Button 1");
JButton button2 = new JButton("Button 2");
JButton button3 = new JButton("Button 3");
JButton button4 = new JButton("Button 4");
JButton button5 = new JButton("Button 5");
JPanel xP=new JPanel();
JPanel yP=new JPanel();
public void init() {
Container cp = getContentPane();
FlowLayout layout=new FlowLayout();
cp.setLayout(layout);
cp.add(xP);
cp.add(yP);
BoxLayout layout1=new BoxLayout(xP,BoxLayout.X_AXIS);
xP.setLayout(layout1);
xP.add(button1);
xP.add(button2);
xP.add(button3);
BoxLayout layout2=new BoxLayout(yP,BoxLayout.Y_AXIS);
yP.setLayout(layout2);
yP.add(button4);
yP.add(button5);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -