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

📄 bugsystem.java

📁 code for implementing a bug control system
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
import java.text.*;
import java.io.*;
					//ADMIN'S SYSTEM

public class BugSystem extends JFrame implements ActionListener
{

	 JDesktopPane desktop = new JDesktopPane ();
	 JMenuBar bar;
	 JMenu mnuAdd,mnuSearch;
	 JMenuItem newProj, newEmp,end,proj;	
	 JPanel statusBar = new JPanel ();
	 JLabel lbStatus;	
	 JLabel lbWelcome;	

	//Getting the Current System Date.
	private java.util.Date currDate = new java.util.Date ();					//Creating Object.
	private SimpleDateFormat sdf = new SimpleDateFormat ("dd MMMM yyyy", Locale.getDefault());	//Changing Format.
	private String d = sdf.format (currDate);	
	
	private Connection con;		
	private Statement st;		
	private String userName;	
	
	public BugSystem (int type, Connection conn)
	{
		super ("Bug Tracking System.");
		setSize (700, 550);
		addWindowListener (new WindowAdapter () {		//Attaching the WindowListener to Program.
			public void windowClosing (WindowEvent we) {	//Overriding the windowClosing Function.
				quitApp ();				//Call the Function to Perform the Closing Action.
			}
		}
		);
		bar = new JMenuBar ();		
		setJMenuBar (bar);		
		mnuAdd = new JMenu ("Display Details");
		mnuSearch = new JMenu ("Assign Project");
	
		newProj = new JMenuItem ("Employees");
		newProj.addActionListener (this);
		newEmp = new JMenuItem ("Projects");
		newEmp.addActionListener (this);
		end = new JMenuItem ("Quit BugSystem ?");
		end.addActionListener (this);
			
		proj = new JMenuItem ("Assign new Project");
		proj.addActionListener (this);
		//findemp = new JMenuItem ("Search Employee");
		//findemp.addActionListener (this);
		

	mnuAdd.add (newProj);
	mnuAdd.add (newEmp);
	mnuAdd.addSeparator ();
	mnuAdd.add (end);
	mnuSearch.add (proj);
	//mnuSearch.add (findemp);
	
	bar.add (mnuAdd);
	bar.add (mnuSearch);
	
	lbStatus = new JLabel (" " + "Bug Tracking System.", Label.LEFT);
	lbStatus.setForeground (Color.black);
	lbWelcome = new JLabel ("Welcome  Admin Today is " + d + " ", JLabel.RIGHT);
	lbWelcome.setForeground (Color.black);
	statusBar.setLayout (new BorderLayout());
	statusBar.add (lbStatus, BorderLayout.WEST);
	statusBar.add (lbWelcome, BorderLayout.EAST);

	getContentPane().add (desktop, BorderLayout.CENTER);
	getContentPane().add (statusBar, BorderLayout.SOUTH);

	//Getting the Database.

	con = conn;
	setVisible (true);
	
	}	
	
	public void actionPerformed (ActionEvent ae) {
		
		Object obj = ae.getSource();
		if (obj == newProj  ) 
		{
			boolean b = openChildWindow ("Displaying All Projects");
			if (b == false)
				{
				//Dispproj dispproj = new Dispproj (con);
				//desktop.add (dispproj);			//Adding Child Window to DesktopPane.
				//dispproj.show ();				//Showing the Child Window.
				}

		}
		else if (obj == newEmp  ) 
		{

			boolean b = openChildWindow ("Displaying all Employees");
			if (b == false) 
			{
				//Dispemp dispemp = new Dispemp (con);
				//desktop.add (dispemp);
				//dispemp.show ();
				
			} 

		}
		
		else if (obj == end) {

			quitApp ();	//Calling the Function to Quit the Program.

		}

		else if (obj == proj  ) 
		{

			boolean b = openChildWindow ("Assign New Project");
			if (b == false) 
			{
				//Asproj asproj = new Asproj (con);
				//desktop.add (asproj);
				//asproj.show ();
			} 

		}
		
		}
	
	private boolean openChildWindow (String title) 
		{
		JInternalFrame[] childs = desktop.getAllFrames ();		//Get All Open Child Windows.
		for (int i = 0; i < childs.length; i++) {
			if (childs[i].getTitle().equalsIgnoreCase (title)) {	//Getting the Title of Child Window.
				childs[i].show ();				//Setting Focus on the Child Window.
				return true;
			}
		}
		return false;
		}
	private void quitApp () 
	{
		try {
			//Show a Confirmation Dialog.
		    	int reply = JOptionPane.showConfirmDialog (this, 
				"Do you really want to exit From\n Bug Tracking System?",
				"BugSystem - Exit", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);
			//Check the User Selection.
			if (reply == JOptionPane.YES_OPTION) {				//If User's Choice Yes then.
				setVisible (false);					//Hide the Frame.
				dispose();            					//Free the System Resources.
				System.exit (0);        				//Close the Application.
			}
			else if (reply == JOptionPane.NO_OPTION) {			//If User's Choice No then.
				setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);	//Do Nothing Return to Program.
			}
		} 

		catch (Exception e) {}
	}
}

⌨️ 快捷键说明

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