📄 systemset.java
字号:
package Barber;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import javax.swing.JButton;
import Barber.Mainpage;
import javax.swing.JPasswordField;
import javax.swing.ImageIcon;
import java.awt.Dimension;
import java.awt.Color;
public class Systemset extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private Mainpage mainpage;
private JButton jButton = null;
private JButton jButton1 = null;
private JPasswordField jPasswordField = null;
private JPasswordField jPasswordField1 = null;
private JPasswordField jPasswordField2 = null;
private JLabel jLabel = null;
/**
* This is the default constructor
*/
public Systemset() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;
this.setBounds(new Rectangle((screenWidth - 636)/ 2,(screenHeight - 537)/ 2, 636, 537));
this.setContentPane(getJContentPane());
this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Barber/top.jpg")));
this.setTitle("HIT理发店管理系统");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(0, 0, 390, 510));
jLabel.setIcon(new ImageIcon(getClass().getResource("/Barber/gif4.gif")));
jLabel.setText("JLabel");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(461, 160, 82, 28));
jLabel3.setForeground(Color.white);
jLabel3.setText("请输入新密码");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(464, 271, 80, 30));
jLabel2.setBackground(new Color(204, 204, 255));
jLabel2.setForeground(Color.white);
jLabel2.setText("请确认新密码");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(460, 45, 81, 29));
jLabel1.setForeground(Color.white);
jLabel1.setText("请输入旧密码");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setBackground(new Color(204, 0, 102));
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(jLabel3, null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(getJPasswordField(), null);
jContentPane.add(getJPasswordField1(), null);
jContentPane.add(getJPasswordField2(), null);
jContentPane.add(jLabel, null);
}
return jContentPane;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton()
{
if (jButton == null)
{
jButton = new JButton();
jButton.setBounds(new Rectangle(419, 419, 77, 26));
jButton.setIcon(new ImageIcon(getClass().getResource("/Barber/other.jpg")));
jButton.setText("");
jButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
setVisible(true);
int xflag = PasswordCheck();
if(xflag == 1)
{
setVisible(false);
if(mainpage==null)
{
mainpage=new Mainpage();
mainpage.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainpage.setVisible(true);
}
}
}
public int PasswordCheck()
{
try{
BufferedReader in = new BufferedReader(new FileReader("Password.ini"));
String SecretCode = in.readLine();
String Password = jPasswordField.getText();
if((SecretCode.equals(Password)))
{
String str1 = jPasswordField1.getText();
String str2 = jPasswordField2.getText();
int Node = 0;
if(str1.equals(str2))
{
PrintWriter out = new PrintWriter("Password.ini");
out.println(str1);
out.close();
JOptionPane.showMessageDialog(null," 密码成功修改","Success",JOptionPane.PLAIN_MESSAGE);
setVisible(false);
if(mainpage==null)
{
mainpage=new Mainpage();
mainpage.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainpage.setVisible(true);
}
return 1;
}
else
{
JOptionPane.showMessageDialog(null, " 修改密码失败!", "Failure", JOptionPane.WARNING_MESSAGE);
return 0;
}
}
else
{
JOptionPane.showMessageDialog(null," 密码错误!","Failure",JOptionPane.WARNING_MESSAGE);
return 0;
}
}
catch(IOException z) {return 0;}
}
public int NOCheck(String str1, String str2)
{
if(str1.equals(str2))
{
return 1;
}
else return 0;
}
});
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(526, 419, 76, 26));
jButton1.setIcon(new ImageIcon(getClass().getResource("/Barber/other2.jpg")));
jButton1.setText("");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
setVisible(false);
if(mainpage==null)
{
mainpage=new Mainpage();
mainpage.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainpage.setVisible(true);
}
}
});
}
return jButton1;
}
/**
* This method initializes jPasswordField
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField() {
if (jPasswordField == null) {
jPasswordField = new JPasswordField();
jPasswordField.setBounds(new Rectangle(449, 89, 113, 22));
}
return jPasswordField;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JPasswordField getJPasswordField1() {
if (jPasswordField1 == null) {
jPasswordField1 = new JPasswordField();
jPasswordField1.setBounds(new Rectangle(450, 209, 112, 25));
}
return jPasswordField1;
}
/**
* This method initializes jTextField1
*
* @return javax.swing.JTextField
*/
private JPasswordField getJPasswordField2() {
if (jPasswordField2 == null) {
jPasswordField2 = new JPasswordField();
jPasswordField2.setBounds(new Rectangle(449, 324, 112, 26));
}
return jPasswordField2;
}
} // @jve:decl-index=0:visual-constraint="95,10"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -