?? nulllayoutdemo.java
字號:
import javax.swing.*;
import java.awt.*;
public class NULLLayoutDemo extends JFrame {
private JLabel lbUser = new JLabel();
private JLabel lbPassword = new JLabel();
private JTextField tfUser = new JTextField();
private JTextField tfPassword = new JTextField();
private JButton btnLog = new JButton();
private Container contrainer =getContentPane();
public NULLLayoutDemo() {
super("空布局");
this.setSize(350,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
}
public static void main(String[] args) {
NULLLayoutDemo frame = new NULLLayoutDemo();
frame.setLayout();
frame.show();
}
public void setLayout( ) {
contrainer.setLayout(null);
lbUser.setText("用戶名");
contrainer.add(lbUser);
lbUser.setBounds(16, 26, 42, 16);
lbPassword.setText("密碼");
contrainer.add(lbPassword);
lbPassword.setBounds(16, 56, 40, 16);
contrainer.add(tfUser);
tfUser.setBounds(73, 25, 255, 22);
contrainer.add(tfPassword);
tfPassword.setBounds(73, 57, 253, 22);
btnLog.setText("登錄");
contrainer.add(btnLog);
btnLog.setBounds(125, 101, 73, 25);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -