📄 gbcall.java
字号:
/**
*A simple program using components within a panel with GridBagLayout
*2004.12.4.
*/
import java.awt.*;
import java.awt.event.*;
public class GBCall extends Frame
{
Panel pTime = new Panel();
Panel pApp = new Panel();
TextField txTime9 = new TextField("09:00");
TextField txTime930 = new TextField("09:30");
TextField txApp = new TextField("Meeting ");
GridBagLayout gb1 = new GridBagLayout();
GridBagLayout gb2 = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
public static void main(String args[])
{
GBCall gbc = new GBCall();
gbc.setLayout(new FlowLayout());
}
public GBCall()
{
setLayout(gb1);
pTime.setLayout(gb2);
gbc.gridx = 0;
gbc.gridy = 0;
pTime.add(txTime9,gbc);
gbc.gridx = 0;
gbc.gridy = 1;
pTime.add(txTime930,gbc);
pTime.setBackground(Color.red);
//RE-using gbc for the main panel layout!!!
gbc.gridx = 0;
gbc.gridy = 0;
gbc.ipadx = 30;
add(pTime,gbc);
pApp.setLayout(gb2);
gbc.gridx = 0;
gbc.gridy = 1;
pApp.add(txApp,gbc);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.ipadx = 100;
pApp.setBackground(Color.lightGray);
add(pApp,gbc);
setSize(300,300);
setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -