1 import java.awt.Image; 2 import javax.swing.ButtonGroup; 3 import javax.swing.Icon; 4 import javax.swing.ImageIcon; 5 import javax.swing.JButton; 6 import javax.swing.JCheckBox; 7 import javax.swing.JComboBox; 8 import javax.swing.JFrame; 9 import javax.swing.JLabel; 10 import javax.swing.JRadioButton; 11 import javax.swing.JTextField; 12 13 public class QQLogin extends JFrame { 14 15 public QQLogin(){ 16 17 this.setTitle("QQ"); 18 this.setLayout(null); 19 20 //建立上部圖片 21 JLabel imgLabel_1 = new JLabel(); 22 Image img_1 = new ImageIcon("img/1.png").getImage(); 23 img_1 = img_1.getScaledInstance(600, 200, 1); 24 imgLabel_1.setIcon(new ImageIcon(img_1)); 25 imgLabel_1.setBounds(0,0,600, 200); 26 this.add(imgLabel_1); 27 28 //建立用戶頭像 29 JLabel imgLabel_2 = new JLabel(); 30 Image img_2 = new ImageIcon("img/2.JPG").getImage(); 31 img_2 = img_2.getScaledInstance(150, 120, 1); 32 imgLabel_2.setIcon(new ImageIcon(img_2)); 33 imgLabel_2.setBounds(55,222,150, 120); 34 this.add(imgLabel_2); 35 36 //建立「多帳號登陸」 圖標 37 JLabel imgLabel_3 = new JLabel(); 38 Image img_3 = new ImageIcon("img/3.png").getImage(); 39 img_3 = img_3.getScaledInstance(35, 35, 1); 40 imgLabel_3.setIcon(new ImageIcon(img_3)); 41 imgLabel_3.setBounds(0,392,35, 35); 42 this.add(imgLabel_3); 43 44 //建立「二維碼」 圖標 45 JLabel imgLabel_4 = new JLabel(); 46 Image img_4 = new ImageIcon("img/4.png").getImage(); 47 img_4 = img_4.getScaledInstance(35, 35, 1); 48 imgLabel_4.setIcon(new ImageIcon(img_4)); 49 imgLabel_4.setBounds(550,386,35, 35); 50 this.add(imgLabel_4); 51 52 53 //建立帳號登陸欄 54 JComboBox box = new JComboBox(); 55 box.addItem("1237322"); 56 box.addItem("2143562"); 57 box.addItem("123244"); 58 box.setBounds(225,222,230,25); 59 this.add(box); 60 61 //建立密碼輸入框 62 JTextField jtxt = new JTextField(); 63 jtxt.setBounds(225,272,230,25); 64 this.add(jtxt); 65 66 //建立 「記住密碼」 複選框 67 JCheckBox jc_1 = new JCheckBox("記住密碼"); 68 jc_1.setBounds(225,322,115,25); 69 this.add(jc_1); 70 71 //建立 「自動登陸」 複選框 72 JCheckBox jc_2 = new JCheckBox("自動登陸"); 73 jc_2.setBounds(380,322,115,25); 74 this.add(jc_2); 75 76 //建立 「註冊帳號」 按鈕 77 JButton button_1 =new JButton("註冊帳號"); 78 button_1.setBounds(460,222,100,25); 79 this.add(button_1); 80 81 //建立 「找回密碼」 按鈕 82 JButton button_2 =new JButton("找回密碼"); 83 button_2.setBounds(460,272,100,25); 84 this.add(button_2); 85 86 //建立 「登陸」 按鈕 87 JButton button_3 =new JButton("登陸"); 88 button_3.setBounds(225,372,230,35); 89 this.add(button_3); 90 91 this.setSize(600, 460); 92 this.setVisible(true); 93 this.setDefaultCloseOperation(3); 94 this.setLocationRelativeTo(null); 95 } 96 public static void main(String[] args) { 97 //生成QQ登陸器 98 QQLogin QQ = new QQLogin (); 99 } 100 101 }