?? 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 + -