📄 manage.java
字号:
package Java;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Toolkit;
public class Manage extends JFrame implements ActionListener {
private String username,userpassword,userpopedom;
JButton _jbuser,_jbno,_jbcount,_jbhelp,_jbexit;
JPanel _jp1,_jp2,_jp3,_jp4;
JLabel _jlwelcome;
Conn conn = new Conn();
public Manage(String username,String userpassword,String popedom) {
super("火车票系统管理");
this.username = username;
this.userpassword = userpassword;
userpopedom = popedom;
if(conn.ifadmin(username,userpassword,userpopedom))
{
}else{
JOptionPane.showMessageDialog(this,"非法请求!");
System.exit(0);
}
JLabel imagelabel = new JLabel();
ImageIcon icon = new ImageIcon("Images/logo.jpg");
imagelabel.setIcon(icon);
repaint();
_jlwelcome = new JLabel("欢迎管理员[ "+username+" ]登录!");
_jlwelcome.setFont(new Font("黑体",java.awt.Font.BOLD,18));
_jlwelcome.setForeground(Color.RED);
_jbuser = new JButton("用户管理");
_jbuser.addActionListener(this);
_jbno = new JButton("车次管理");
_jbno.addActionListener(this);
_jbcount = new JButton("票务统计");
_jbcount.addActionListener(this);
_jbhelp = new JButton("系统帮助");
_jbhelp.addActionListener(this);
_jbexit = new JButton("退出系统");
_jbexit.addActionListener(this);
_jp1 = new JPanel();
_jp2 = new JPanel();
_jp3 = new JPanel();
_jp4 = new JPanel(new GridLayout(2,1));
_jp1.add(imagelabel);
_jp2.add(_jbuser);
_jp2.add(_jbno);
_jp2.add(_jbcount);
_jp2.add(_jbhelp);
_jp3.add(_jbexit);
_jp4.add(_jp2);
_jp4.add(_jp3);
this.add(_jlwelcome,"North");
this.add(_jp1,"Center");
this.add(_jp4,"South");
pack();
this.setVisible(true);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
int W = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
int H = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();
this.setLocation((W - this.getWidth())/2,(H - this.getHeight())/2);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==_jbuser)
{
dispose();
new Usermanage(username,userpassword,userpopedom);
}
if(e.getSource()==_jbno)
{
JOptionPane.showMessageDialog(this,"正在准备中……");
}
if(e.getSource()==_jbcount)
{
dispose();
new Ticketmanage(username,userpassword,userpopedom);
}
if(e.getSource()==_jbhelp)
{
new Help();
}
if(e.getSource()==_jbexit)
{
dispose();
JOptionPane.showMessageDialog(this,"谢谢使用,您已经安全退出!");
new Login();
}
}
public static void main (String[] args) {
new Manage("sain","123","admin");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -