📄 9_1_030421217.java
字号:
import javax.swing.*;
import java.awt.*;
public class GblTest extends JFrame
{
GblTest(String a)
{
super(a);
}
public static void main(String[] args)
{
GblTest frame=new GblTest("GridBagLayoutTest");
GridBagLayout gridBagLayout=new GridBagLayout();
GridBagConstraints gridBagConstraints1=new GridBagConstraints();
frame.setSize(300,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(gridBagLayout);
JButton jbutton1=new JButton("Button1");
JButton jbutton2=new JButton("Button2");
JButton jbutton3=new JButton("Button3");
JButton jbutton4=new JButton("Button4");
JButton jbutton5=new JButton("Button5");
JButton buttontemp=new JButton();
Container container=frame.getContentPane();
gridBagConstraints1.gridx=0;
gridBagConstraints1.gridy=0;
gridBagConstraints1.fill=GridBagConstraints.BOTH;
gridBagLayout.setConstraints(jbutton1,gridBagConstraints1);
container.add(jbutton1);
gridBagConstraints1.gridx=2;
gridBagConstraints1.gridy=0;
gridBagLayout.setConstraints(jbutton2,gridBagConstraints1);
container.add(jbutton2);
gridBagConstraints1.gridx=1;
gridBagConstraints1.gridy=1;
gridBagLayout.setConstraints(jbutton3,gridBagConstraints1);
container.add(jbutton3);
gridBagConstraints1.gridx=0;
gridBagConstraints1.gridy=2;
gridBagLayout.setConstraints(jbutton4,gridBagConstraints1);
container.add(jbutton4);
gridBagConstraints1.gridx=2;
gridBagConstraints1.gridy=2;
gridBagLayout.setConstraints(jbutton5,gridBagConstraints1);
container.add(jbutton5);
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -