⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manageframe.java

📁 一个学籍管理系统。
💻 JAVA
字号:
/*
 * Created on 2004-5-30
 */
/**
 * @author Zhou Qi
 */
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;
import javax.swing.border.*;

import javax.swing.plaf.metal.*;



public class ManageFrame extends JFrame
{
	JMenuBar menuBar;
	JDesktopPane desktop;
	JInternalFrame toolPalette;
	
	static final Integer DOCLAYER = new Integer(5);
	static final Integer TOOLLAYER = new Integer(6);
	static final Integer HELPLAYER = new Integer(7);

	static final String ABOUTMSG = "Student Manage System[Version 1.0.0] \n \nHomework for <Thinking In Java>. \n \nWritten by zhou_qi@sjtu.edu.cn" +
		"\n Refer to javademos ";
	static final String AUTHORMSG="Author: 周 琦\nClass: F0203306 Number: 5020339142    \n"+
	"Email: zhou_qi@sjtu.edu.cn";


	public ManageFrame()
	{
		super("Student Manage System         [Version 1.0.0]");
		final int inset = 50;
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	    setBounds ( inset, inset, screenSize.width - inset*2, screenSize.height - inset*2 );
	    buildContent();
	    buildMenus();
		
	    this.addWindowListener(new WindowAdapter()
	    {
	    	public void windowClosing(WindowEvent e)
	    	{
	    		quit();
	    	}
	    });
	//UIManager.addPropertyChangeListener(new UISwitchListener((JComponent)getRootPane()));
	}

	protected void buildMenus()
	{
		menuBar = new JMenuBar();
		menuBar.setOpaque(true);
		JMenu
		 menuFile=buildFileMenu(),
		 menuLogin=buildLoginMenu(),
		 menuManage=buildManageMenu(),
		 menuHelp=buildHelpMenu();
	   
	// load a theme from a text file
	MetalTheme myTheme = null;
	try
	{
		myTheme=new PropertiesMetalTheme(new FileInputStream("MyTheme.theme"));
	} 
	catch (IOException e) {System.out.println(e);}

	menuBar.add(menuFile);
	menuBar.add(menuLogin);
	menuBar.add(menuManage);
	menuBar.add(menuHelp);
	setJMenuBar(menuBar);	
	}

	protected JMenu buildFileMenu()
	{
		JMenu file=new JMenu("File");
	    JMenuItem
		 fileTestConnection=new JMenuItem("Test Connection",KeyEvent.VK_T),
		 fileBackupFile=new JMenuItem("Backup File",KeyEvent.VK_B),
		 fileExit=new JMenuItem("Exit",KeyEvent.VK_X);
	fileBackupFile.setIcon(new ImageIcon("Image/backup.gif"));
	fileTestConnection.setIcon(new ImageIcon("Image/connection.gif"));
	fileExit.setIcon(new ImageIcon("Image/exit.gif"));
		

	fileTestConnection.addActionListener(new ActionListener()
	{   public void actionPerformed(ActionEvent e)
		{
			boolean ok=true;
			try
			{
				Access myaccess=Access.getAccess();
			}
			catch(Exception ex)
			{
				ok=false;
				connectionError();
			}
			finally
			{
				if(ok)
				{
					connectionSuccess();
				}
			}
		}
		});

	fileExit.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{	
			System.exit(0);					
		}});

	file.add(fileTestConnection);
	file.add(fileBackupFile);
	file.addSeparator();
	file.add(fileExit);
	return file;
	}

	protected JMenu buildLoginMenu()
	{
	JMenu login= new JMenu("Login");
	JMenuItem
	 loginStudent=new JMenuItem("Student",KeyEvent.VK_S),
	 loginTeacher=new JMenuItem("Teacher",KeyEvent.VK_T),
	 loginAdmin=new JMenuItem("Administrator",KeyEvent.VK_A),
	 logout=new JMenuItem("Log Out",KeyEvent.VK_O);
	 
	loginStudent.setIcon(new ImageIcon("Image/student.gif"));
	loginTeacher.setIcon(new ImageIcon("Image/teacher.gif"));
	loginAdmin.setIcon(new ImageIcon("Image/admin.gif"));
	logout.setIcon(new ImageIcon("Image/logout.gif"));
	
	loginStudent.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{	
			login(1);					
		}});
	loginTeacher.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{	
			login(2);					
		}});
	loginAdmin.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{	
			login(3);					
		}});
	login.add(loginStudent);
	login.add(loginTeacher);
	login.add(loginAdmin);
	login.addSeparator();
	login.add(logout);

	return login;
	}
	protected  JMenu buildManageMenu()
	{
		JMenu manage=new JMenu("Manage");
		return manage;
	}
	protected JMenu buildHelpMenu()
	{
		JMenu help = new JMenu("Help");
		JMenuItem about = new JMenuItem("About System",KeyEvent.VK_S);
		JMenuItem openHelp = new JMenuItem("About Author",KeyEvent.VK_A);

		about.setIcon(new ImageIcon("Image/information.gif"));
		openHelp.setIcon(new ImageIcon("Image/author.gif"));
		about.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				showAboutBox();
			}
		});
		openHelp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
					showAuthor();
			}
		});

		help.add(about);
		help.addSeparator();
		help.add(openHelp);

		return help;
	}

	protected void buildContent()
	{
		desktop = new JDesktopPane();
		getContentPane().add(desktop);
	}
	public void login(int i)
	{
		//JInternalFrame doc = new Login(i);
		JInternalFrame doc=new Login(i);
		desktop.add(doc, DOCLAYER);
		try { 
			doc.setVisible(true);
			doc.setSelected(true); 
		} catch (java.beans.PropertyVetoException e2) {}
	}
	public void quit()
	{
		System.exit(0);
	}
    public void showAuthor()
    {
		JOptionPane.showMessageDialog(this,AUTHORMSG);
    }
	public void showAboutBox() {
		JOptionPane.showMessageDialog(this, ABOUTMSG);
	}
	public void connectionError()
	{
		String empty="Connection Error!\nPlease config User's DSN   \nfor Student.mdb";
		JOptionPane.showMessageDialog(null,empty,"Error",JOptionPane.OK_OPTION);
	}
	public void connectionSuccess()
	{
		String empty="Connection success!\nYou can use all the functions!  ";
		JOptionPane.showMessageDialog(null,empty);
		
	}

	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -