package FileManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.awt.Panel;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
public class Administrator extends User
{
Administrator(String name,String password,String role)
{
super(name,password,role);
}
public void showMenu() throws IOException
{
JFrame adminMenu = new JFrame("管理人员菜单");
//[start]窗口设置
// 使用Toolkit可以获得本机系统的屏幕的参数
Toolkit toolkit = adminMenu.getToolkit();
Dimension dim = toolkit.getScreenSize();
adminMenu.setSize(400,320);
adminMenu.setLocation((dim.width-adminMenu.getWidth())/2,(dim.height-adminMenu.getHeight())/2);
adminMenu.setVisible(true);
//[end]
changePw = new JButton("修改密码");
scanFile = new JButton("浏览文件");
downFile = new JButton("下载文件");
JButton changeUser = new JButton("修改用户");
JButton addUser = new JButton("增加用户");
JButton delUser = new JButton("删除用户");
JButton listUser = new JButton("列出用户");
back = new JButton("返回上级");
//[start]添加背景图
JPanel pane = new JPanel();
adminMenu.setContentPane(pane);
ImageIcon img = new ImageIcon("src/images/adminMenu.png");
JLabel imageLabel = new JLabel(img);
pane.add(imageLabel);
//[end]
JMenuBar menuBar = new JMenuBar();
adminMenu.setJMenuBar(menuBar);
JMenu menuUser = new JMenu("用户管理");
menuBar.add(menuUser);
menuUser.add(changePw);
menuUser.add(scanFile);
menuUser.add(downFile);
menuUser.add(changeUser);
menuUser.add(addUser);
menuUser.add(delUser);
menuUser.add(listUser);
menuUser.add(back);
changePw.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0) {
JFrame changePw = new JFrame("修改密码");
// 使用Toolkit可以获得本机系统的屏幕的参数
Toolkit toolkit = changePw.getToolkit();
Dimension dim = toolkit.getScreenSize();
changePw.setSize(400,200);
changePw.setLocation((dim.width-changePw.getWidth())/2,(dim.height-changePw.getHeight())/2);
changePw.setVisible(true);
JLabel label1 = new JLabel("原密码:");
JLabel label2 = new JLabel("新密码:");
JLabel label3 = new JLabel("确认密码:");
JPasswordField psf1 = new JPasswordField();
JPasswordField psf2 = new JPasswordField();
JPasswordField psf3 = new JPasswordField();
JButton bt1 = new JButton("确认");
JButton bt2 = new JButton("取消");
Panel p = new Panel();
p.add(bt1);
p.add(bt2);
// 为指定的 Container 创建 GroupLayout
GroupLayout layout = new GroupLayout(changePw.getContentPane());
changePw.getContentPane().setLayout(layout);
// 创建GroupLayout的水平连续组,,越先加入的ParallelGroup,优先级级别越高。
GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
hGroup.addGap(5);// 添加间隔
hGroup.addGroup(layout.createParallelGroup().addComponent(label1).addComponent(label2).addComponent(label3));
hGroup.addGap(5);
hGroup.addGroup(layout.createParallelGroup().addComponent(psf1).addComponent(psf2)
.addComponent(psf3).addComponent(p));
hGroup.addGap(5);
layout.setHorizontalGroup(hGroup);
// 创建GroupLayout的垂直连续组,,越先加入的ParallelGroup,优先级级别越高。
GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
vGroup.addGap(10);
vGroup.addGroup(layout.createParallelGroup().addComponent(label1).addComponent(psf1));
vGroup.addGap(10);
vGroup.addGroup(layout.createParallelGroup().addComponent(label2).addComponent(psf2));
vGroup.addGap(10);
vGroup.addGroup(layout.createParallelGroup().addComponent(label3).addComponent(psf3));
vGroup.addGap(10);
vGroup.addGroup(layout.createParallelGroup().addComponent(p));
vGroup.addGap(10);
// 设置垂直组
layout.setVerticalGroup(vGroup);
bt1.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String ps1,ps2,ps3;
ps1=psf1.getText();
ps2=psf2.getText();
ps3=psf3.getText();
if(!ps1.equals(getPassword()))
{
JOptionPane.showMessageDialog(null, "原密码输入错误!", "错误", JOptionPane.ERROR_MESSAGE);
psf1.setText("");
psf2.setText("");
psf3.setText("");
}
else if(!ps2.equals(ps3))
{
JOptionPane.showMessageDialog(null, "两次密码输入不一样!", "错误", JOptionPane.ERROR_MESSAGE);
psf1.setText("");
psf2.setText("");
psf3.setText("");
}
else if(ps1.equals(ps2))
{
JOptionPane.showMessageDialog(null, "新密码和原密码一样!", "错误", JOptionPane.ERROR_MESSAGE);
psf1.setText("");
psf2.setText("");
psf3.setText("");
}
else
{
try {
changeUserInfo(ps2);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
JOptionPane.showMessageDialog(null, "修改密码成功!", "提示", JOptionPane.INFORMATION_MESSAGE);
}
}
});
bt2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
changePw.dispose();
}
});
}
});
scanFile.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
try {
new ScanAndDown();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
downFile.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
try {
new ScanAndDown();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
changeUser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
JFrame changeUser = new JFrame("修改用户");
// 使用Toolkit可以获得本机系统的屏幕的参数
Toolkit toolkit = changePw.getToolkit();
Dimension dim = toolkit.getScreenSize();
changeUser.setSize(400,175);
changeUser.setLocation((dim.width-changeUser.getWidth())/2,(dim.height-changeUser.getHeight())/2);
changeUser.setVisible(true);
JLabel user = new JLabel("用户名:");
JTextField tf = new JTextField();
JLabel type = new JLabel("类型:");
JComboBox<String> cmbJRole;
String[] strRoles = { "Administrator", "Operator", "Browser" };
cmbJRole = new JComboBox<String>(strRoles);
cmbJRole.setBounds(121, 118, 131, 21);
changeUser.add(cmbJRole);
JButton bt1 = new JButton("确认");
JButton bt2 = new JButton("取消");
Panel p = new Panel();
p.add(bt1);
没有合适的资源?快使用搜索试试~ 我知道了~
Java文件管理系统
共73个文件
class:57个
java:10个
png:2个
需积分: 50 33 下载量 140 浏览量
2018-01-30
16:08:06
上传
评论 4
收藏 104KB ZIP 举报
温馨提示
一个文件管理系统,可以根据登录人员的不同身份显示不同的管理界面,可以实现文件的上传下载,对登录人员相关信息的修改增加删除,实现了网络编程和多线程。
资源推荐
资源详情
资源评论
收起资源包目录
实验.zip (73个子文件)
实验
.project 382B
src
images
adminMenu.png 5KB
FileManager
User.java 2KB
Administrator.java 21KB
Doc.java 1KB
UserSQL.java 2KB
Browser.java 13KB
TcpClient.java 849B
UserAddTest.java 4KB
Main.java 6KB
Operator.java 13KB
DataProcessing.java 14KB
.settings
org.eclipse.jdt.core.prefs 598B
2.bmp 2.14MB
.classpath 406B
bin
images
adminMenu.png 5KB
FileManager
Browser$2.class 845B
User.class 3KB
ScanAndDown$3.class 904B
Administrator$1.class 4KB
Browser$1$1.class 2KB
Operator$2.class 4KB
Administrator$4.class 4KB
LoginFrame.class 4KB
Administrator$4$2.class 833B
Operator$6.class 1009B
Operator$1.class 4KB
Operator$4.class 851B
Browser$3.class 845B
UserSQL.class 2KB
Administrator.class 4KB
Administrator$4$1.class 2KB
Main.class 560B
Operator$5.class 795B
TcpClient.class 1KB
UserAddTest$3.class 574B
ScanAndDown$1.class 854B
UserAddTest$1.class 3KB
Administrator$3.class 881B
ListAndDel$1.class 873B
LoginFrame$1.class 2KB
Administrator$1$1.class 2KB
LoginFrame$1$1.class 967B
Administrator$6.class 959B
Administrator$8.class 828B
ListAndDel$2.class 2KB
Administrator$1$2.class 831B
Operator$2$2.class 799B
Administrator$5$2.class 833B
Operator.class 3KB
ScanAndDown$2.class 3KB
Browser$5.class 1006B
Operator$3.class 851B
ListAndDel$3.class 934B
Doc.class 2KB
Browser$4.class 792B
Browser.class 3KB
UserAddTest$2.class 1KB
Administrator$7.class 959B
Administrator$2.class 881B
Administrator$5$1.class 2KB
Operator$2$1.class 3KB
LoginFrame$2.class 702B
DataProcessing.class 6KB
Administrator$5.class 4KB
Operator$1$2.class 1000B
UserAddTest.class 3KB
Operator$1$1.class 2KB
ListAndDel.class 3KB
ScanAndDown.class 3KB
Browser$1$2.class 994B
Browser$1.class 4KB
Administrator$9.class 1KB
共 73 条
- 1
资源评论
勿匆
- 粉丝: 5
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功