java UI之QQ登入
阿新 • • 發佈:2019-02-06
package com.SwingIn51; import java.awt.*; import javax.swing.*; public class QQLanuch extends JFrame{ JLabel label_North;//北部 JButton button_South1,button_South2,button_South3;//南部 JPanel panel_South1; JTabbedPane tabbedPane;//中部 JPanel panel_Center2,panel_Center3,panel_Center4; JLabel label2,label3,label4,label5; JTextField textField; JPasswordField passwordField; JButton button4; JCheckBox checkBox1,checkBox2; public QQLanuch() { label2=new JLabel("QQ號碼:",JLabel.CENTER); label3=new JLabel("QQ密碼:",JLabel.CENTER); label4=new JLabel("忘記密碼:",JLabel.CENTER); label4.setFont(new Font("宋體",Font.PLAIN,16));//設定字型 label4.setForeground(Color.BLUE);//設定字型顏色 label5=new JLabel("<html><a href='www.qq.com'>申請密碼保護</a>");//設定標籤連結 label5.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//設定指標(指滑鼠的)的預定義樣式 textField=new JTextField(); passwordField=new JPasswordField(); button4=new JButton("清除號碼"); checkBox1=new JCheckBox("隱身登入"); checkBox2=new JCheckBox("記住密碼"); label_North=new JLabel(new ImageIcon("image/car.jpg"));//設定圖片 panel_South1=new JPanel(); button_South1=new JButton("登入"); button_South2=new JButton("取消"); button_South3=new JButton("嚮導"); tabbedPane=new JTabbedPane(); panel_Center2=new JPanel(); panel_Center3=new JPanel(); panel_Center4=new JPanel(); panel_Center3.setBackground(Color .BLACK);//設定面板顏色 panel_Center4.setBackground(Color.BLUE); tabbedPane.add("普通使用者", panel_Center2); tabbedPane.add("QQ會員", panel_Center3); tabbedPane.add("管理員", panel_Center4); panel_Center2.setLayout(new GridLayout(3,3));//面板2位3行3列 panel_South1.add(button_South1); panel_South1.add(button_South2); panel_South1.add(button_South3); panel_Center2.add(label2); panel_Center2.add(textField); panel_Center2.add(button4); panel_Center2.add(label3); panel_Center2.add(passwordField); panel_Center2.add(label4); panel_Center2.add(checkBox1); panel_Center2.add(checkBox2); panel_Center2.add(label5); this.add(panel_South1,BorderLayout.SOUTH);//把三個元件新增到JFame中 this.add(tabbedPane, BorderLayout.CENTER); this.add(label_North, BorderLayout.NORTH); this.setTitle("使用者登入"); this.setSize(340, 270); this.setLocation(300, 280); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); ImageIcon head_Image=new ImageIcon("image/car.jpg");//設定圖示 this.setIconImage(head_Image.getImage()); } public static void main(String[] args) { QQLanuch a=new QQLanuch(); } }