java 密码界面_忘记密码界面
[java]代碼庫//此類是找回密碼
package com.view;
import java.awt.Color;
/**
* 找回密碼
* @author wu2xin
*
*/
public class InTo_Forget extends JFrame implements ActionListener{
/**
* 成員變量
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JPanel panel;
private JLabel nameLab,alertLab,alertImg;
private JTextField nameTex;
private JTextField emailTex;
private JButton delBut;
private JScrollPane scrollPane;
private JLabel alert;
private JTextArea textArea;
private JButton blackBut;
private JCheckBox nameCheck,emailCheck;
private JButton lookBtu;
private JLabel topImage;
/**
* new 出來新窗口
*/
public static void main(String[] args) {
InTo_Forget frame = new InTo_Forget();
frame.setVisible(true);
}
/**
* 構造初始化
*/
public InTo_Forget() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setUndecorated(true);//去掉窗口的裝飾
this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);設置為簡單對話窗口
this.setTitle("找回密碼");
this.setSize(694, 498);
this.setLocationRelativeTo(null);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
alertImg=new JLabel(new ImageIcon("image/search1.gif"));
alertImg.setBounds(0, 21, 60, 45);
contentPane.add(alertImg);
alertLab =new JLabel("找回密碼");
alertLab.setFont(new Font("楷體", Font.BOLD, 20));
alertLab.setLocation(65, 21);
alertLab.setSize(113, 30);
contentPane.add(alertLab);
topImage = new JLabel(new ImageIcon("image/找回密碼插景圖.jpg"));
topImage.setBounds(376, 0, 307, 114);
contentPane.add(topImage);
/**
*操作 面板
*/
panel = new JPanel();
panel.setOpaque(false);//透明
TitledBorder tb=new TitledBorder("歡迎找回密碼");
tb.setTitleFont(new Font("陳代明硬筆體", Font.PLAIN, 20));
tb.setTitleColor(Color.blue);
panel.setBorder(tb);//在Jpanel上打幾個標題
panel.setBounds(0, 104, 684, 298);
contentPane.add(panel);
panel.setLayout(null);
nameCheck = new JCheckBox("按用戶名");
nameCheck.setBounds(3, 33, 82, 30);
nameCheck.setOpaque(false);//透明
nameCheck.addActionListener(this);//監聽1
panel.add(nameCheck);
emailCheck = new JCheckBox("按郵箱");
emailCheck.setBounds(3, 105, 82, 30);
emailCheck.setOpaque(false);//透明
emailCheck.addActionListener(this);//監聽1
panel.add(emailCheck);
nameLab = new JLabel("用戶名:");
nameLab.setForeground(Color.BLUE);
nameLab.setFont(new Font("楷體", Font.BOLD, 16));
nameLab.setHorizontalAlignment(SwingConstants.RIGHT);
nameLab.setBounds(27, 69, 73, 30);
panel.add(nameLab);
nameTex = new JTextField();
nameTex.setBackground(Color.WHITE);
nameTex.setEditable(false);
nameTex.setBounds(110, 68, 123, 30);
panel.add(nameTex);
nameTex.setColumns(10);
JLabel emailLab = new JLabel("郵箱:");
emailLab.setForeground(Color.BLUE);
emailLab.setFont(new Font("楷體", Font.BOLD, 16));
emailLab.setHorizontalAlignment(SwingConstants.RIGHT);
emailLab.setBounds(27, 141, 73, 30);
panel.add(emailLab);
emailTex = new JTextField();
emailTex.setBackground(Color.WHITE);
emailTex.setEditable(false);
emailTex.setColumns(10);
emailTex.setBounds(110, 141, 123, 30);
panel.add(emailTex);
lookBtu= new JButton("查詢");
lookBtu.setBounds(27, 226, 71, 30);
lookBtu.addActionListener(this);//監聽1
panel.add(lookBtu);
delBut = new JButton("清空");
delBut.setBounds(162, 226, 71, 30);
delBut.addActionListener(this);//監聽1
panel.add(delBut);
scrollPane = new JScrollPane();
scrollPane.setBounds(322, 44, 354, 231);
panel.add(scrollPane);
textArea = new JTextArea();
scrollPane.setViewportView(textArea);
alert = new JLabel("信息提示:");
alert.setHorizontalAlignment(SwingConstants.RIGHT);
alert.setForeground(Color.BLACK);
alert.setFont(new Font("楷體", Font.PLAIN, 16));
alert.setBounds(263, 10, 82, 30);
panel.add(alert);
blackBut = new JButton("返回主頁");
blackBut.setBounds(574, 412, 86, 30);
blackBut.addActionListener(this);//監聽1
contentPane.add(blackBut);
JLabel topImg = new JLabel(new ImageIcon("image/forget.jpg"));
topImg.setBounds(0, 0, 686, 498);
contentPane.add(topImg);
this.setVisible(true);//可見
}
/注冊監聽器1(普通事件)
@Override
public void actionPerformed(ActionEvent de) {
// TODO Auto-generated method stub
String id=nameTex.getText();
//String email=emailTex.getText();
AdminModel model=new AdminModel();
if(de.getSource()==nameCheck){//用戶名單選
if(nameCheck.isSelected()){
nameTex.setEditable(true);
emailTex.setEditable(false);
emailCheck.setSelected(false);
}else{
nameTex.setEditable(false);
}
}else if(de.getSource()==emailCheck){//email 單選
if(emailCheck.isSelected()){
nameTex.setEditable(false);
nameCheck.setSelected(false);
emailTex.setEditable(true);
}
}else if(de.getSource()==lookBtu){//查詢
if(StringUtil.isNotNull(id)){
AdminPoJo pojo=model.getAdmin(Integer.parseInt(id));
if(pojo!=null){
textArea.setText(id+",找回成功!\n\t"+pojo.getName()+"你好,你的密碼是:"+pojo.getPassword());
}else{
textArea.setText("對不起,查找失敗,沒有"+id+"該賬號");
}
}else{
JOptionPane.showMessageDialog(null, "請選擇查詢條件");
}
}else if(de.getSource()==delBut){//撤銷
nameTex.setText("");
emailTex.setText("");
textArea.setText("");
}else if(de.getSource()==blackBut){//返回登錄主界面
new InTo();
this.dispose();
}
}
}
總結
以上是生活随笔為你收集整理的java 密码界面_忘记密码界面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【RX解码BT656输出】XS9922A
- 下一篇: 考研数学笔记 - 微分中值定理