package sys;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class adminframe extends JFrame{
private JMenuBar jMenuBar;
private JMenu jMenu1;
private JMenuItem aboutsys;
private JScrollPane jScrollPane;
private JMenuItem copy;
private JPopupMenu pop;
private JPopupMenu cut;
private JPopupMenu paste;
private JPopupMenu popmenu;
private JButton messagebutton;
private JTextArea area;
private JMenuItem aboutauthor;
private JMenu jMenu2;
private JMenuItem modify;
private JMenuItem delete;
private JMenuItem add_data;
private JMenuItem check_no;
private JMenuItem check_all;
private JMenuItem cutItem;
private JMenuItem jMenuItem1;
private JButton savebutton;
private JMenuItem copyItem;
private JMenuItem pasteItem;
private JMenuItem cutItemPop;
{
this.setLayout(null);
this.setDefaultCloseOperation(2);
this.setResizable(false);
this.setSize(460, 352);
this.setLocation(400,300);
this.setTitle("选修课管理系统-管理员界面");
this.setVisible(true);
this.setIconImage(new ImageIcon(getClass().getClassLoader().getResource("sys/java/sims/man.jpg")).getImage());
getContentPane().setBackground(new java.awt.Color(255,255,255));
{
jScrollPane = new JScrollPane();
getContentPane().add(jScrollPane);
jScrollPane.setBounds(52, 0, 390, 253);
jScrollPane.setBackground(new java.awt.Color(146,146,146)); //新建弹出式菜单中的“Copy”菜单项和监听器
{
area = new JTextArea();
jScrollPane.setViewportView(area);
}
}
{
messagebutton = new JButton();
getContentPane().add(messagebutton);
messagebutton.setText("\u67e5\u770b\u7559\u8a00");
messagebutton.setBounds(99, 252, 100, 23);
messagebutton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
new check_m();
}
});
}
{
savebutton = new JButton();
getContentPane().add(savebutton);
savebutton.setText("\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c");
savebutton.setBounds(246, 252, 107, 25);
savebutton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(area.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(null,"结果为空,无须保存");
return;
}
JFileChooser fc=new JFileChooser();
int returnval=fc.showSaveDialog(null);
if(returnval==0)
{
File savefile=fc.getSelectedFile();
try {
FileWriter writeOut = new FileWriter(savefile);
writeOut.write(area.getText().trim());
writeOut.close();
} catch (IOException e1) {
JOptionPane.showMessageDialog(null,"保存失败");
e1.printStackTrace();
}
}
}
});
}
{
jMenuBar = new JMenuBar();
setJMenuBar(jMenuBar);
{
jMenu1 = new JMenu();
jMenuBar.add(jMenu1);
jMenu1.setText("\u6570\u636e\u7ba1\u7406");
jMenu1.setPreferredSize(new java.awt.Dimension(68, 21));
{
check_all = new JMenuItem("全部查询 C",'C');
jMenu1.add(check_all);
check_all.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
area.setText("");
String sql="select * from class";
conn xiaosi=new conn();
ResultSet rs=xiaosi.Query(sql);
area.append("学号" + "\t" + "姓名" + "\t" + "性别"
+ "\t" + "日语" + "\t" + "英语" + "\t"
+ "数学" + "\t" + "Java程序设计" + "\t"
+ "数据库" + "\t" + "数据结构");
try {
while(rs.next())
{
String num = rs.getString(1);
String name = rs.getString(2);
String sex = rs.getString(3);
String jse = rs.getString(4);
String english = rs.getString(5);
String math = rs.getString(6);
String java = rs.getString(7);
String database = rs.getString(8);
String datastruct = rs.getString(9);
String[] str_row={num,name,sex,jse,english,math,java,database,datastruct};
area.append("\n" + num + "\t" + name
+ "\t" + sex + "\t" + jse
+ "\t" + english + "\t" + math
+ "\t" + java + "\t" + database
+ "\t" + datastruct + "\t");
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null,"数据库连接异常,请查看相关错误");
e1.printStackTrace();
}
}
});
}
{
check_no = new JMenuItem("按学号查询 N",'N');
jMenu1.add(check_no);
check_no.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
new check_by_no();
}
});
}
{
add_data = new JMenuItem("添加数据 A",'A');
jMenu1.add(add_data);
add_data.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
new add_data();
}
});
}
{
delete = new JMenuItem("删除数据 D",'D');
jMenu1.add(delete);
delete.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
new deleteframe();
}
});
}
{
modify = new JMenuItem("修改数据 M",'M');
jMenu1.add(modify);
modify.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
new ChangeData();
}
});
}
{
jMenuItem1 = new JMenuItem("单科成绩查询 D",'D');
jMenu1.add(jMenuItem1);
jMenuItem1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
new checkbyk();
}
});
}
}
{
jMenu2 = new JMenu();
jMenuBar.add(jMenu2);
jMenu2.setText("\u5173\u4e8e");
{
aboutsys = new JMenuItem();
jMenu2.add(aboutsys);
aboutsys.setText("\u5173\u4e8e\u7cfb\u7edf");
aboutsys.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new AboutSys();
}
});
}
{
aboutauthor = new JMenuItem();
jMenu2.add(aboutauthor);
aboutauthor.setText("\u51