效果圖html
<ignore_js_op>
java
代碼以下code
- package Game;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- class Qq{
- public void showLoginFrame(){
- final JFrame loginFrame=new JFrame();
- //設置大小,位置,標題
- loginFrame.setSize(300,200);
- loginFrame.setTitle("QQ2014");
- loginFrame.setLocationRelativeTo(null);
- //建立流式分佈對象
- FlowLayout layout=new FlowLayout();
- loginFrame.setLayout(layout);
-
- //建立帳戶名,密碼和輸入框
- JLabel user=new JLabel("帳號:");
- JLabel password=new JLabel("密碼:");
- final JTextField named=new JTextField(20);
- final JPasswordField password2=new JPasswordField(20);
- //建立登錄,重置按鈕
- JButton reset=new JButton("重置");
- JButton login=new JButton("登錄");
-
- //設置窗體可見
- loginFrame.setVisible(true);
-
- //建立事件監聽對象
- ActionListener listener1=new ActionListener(){
- public void actionPerformed(ActionEvent e){
- String name=named.getText();
- String password=password2.getText();
- if("zhaoxin".equals(name)&&"123".equals(password))
- {
- showIndexFrame();
- loginFrame.setDefaultCloseOperation(3);
- loginFrame.setVisible(false);
- }
- else{
- System.out.println("密碼錯誤,從新輸入!");
- }
-
-
- }
- .......
詳細說明:http://java.662p.com/thread-3728-1-1.htmlorm