📄 gridlayoutapplet.java
字号:
import java.awt.*;
import javax.swing.*;
public class GridLayoutApplet extends JApplet {
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
GridLayout gridLayout1 = new GridLayout();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel1 = new JLabel();
FlowLayout flowLayout1 = new FlowLayout();
JTextField jTextField1 = new JTextField();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JTextField jTextField2 = new JTextField();
JTextField jTextField3 = new JTextField();
JTextField jTextField4 = new JTextField();
//Applet初始
public void init() {
try {
myInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//组件初始设置
private void myInit() throws Exception {
this.setSize(new Dimension(247, 192));
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(flowLayout1);
jButton1.setText("查询");
jButton2.setText("取消");
jPanel1.add(jButton1, null);
jPanel1.add(jButton2, null);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("商品货号");
jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
jLabel2.setText("商品名称");
jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
jLabel3.setText("单价");
jLabel4.setHorizontalAlignment(SwingConstants.CENTER);
jLabel4.setText("存货量");
jPanel2.setLayout(gridLayout1);
gridLayout1.setColumns(2);
gridLayout1.setHgap(5);
gridLayout1.setRows(4);
gridLayout1.setVgap(5);
jPanel2.add(jLabel1, null);
jPanel2.add(jTextField1, null);
jPanel2.add(jLabel2, null);
jPanel2.add(jTextField2, null);
jPanel2.add(jLabel3, null);
jPanel2.add(jTextField3, null);
jPanel2.add(jLabel4, null);
jPanel2.add(jTextField4, null);
this.getContentPane().add(jPanel1, BorderLayout.SOUTH);
this.getContentPane().add(jPanel2, BorderLayout.CENTER);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -