?? jcomponentexam.java
字號:
package ch7;
import java.awt.*;
import javax.swing.*;
public class JcomponentExam extends JFrame
{
JTextField name=new JTextField(10);
JPasswordField pass=new JPasswordField();
JButton exit,ok;
public JcomponentExam()
{
Container pane=this.getContentPane();
pane.setLayout(new GridLayout(0,2));
Icon i1=new ImageIcon("./people.gif");
Icon i2=new ImageIcon("./lock.gif");
Icon i3=new ImageIcon("./exit.gif");
Icon i4=new ImageIcon("./mouse.gif");
pane.add(new JLabel("用戶名",i1,0));
pane.add(name);
pane.add(new JLabel("口令",i2,0));
pane.add(pass);
exit=new JButton("退出",i3);
ok=new JButton("登錄",i4);
pane.add(exit);
pane.add(ok);
this.setTitle("用戶登錄"); //設置框架窗口標題
this.setBounds(100,100,300,150); //設置框架窗口的顯示位置及大小
this.setVisible(true); //設置框架窗口是可見的
this.setDefaultCloseOperation(3); //單擊關閉按鈕后,推出程序
}
public static void main(String args[])
{
new JcomponentExam(); //創建對象顯示用戶登錄界面
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -