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

📄 server.java

📁 create the email in the server
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		       serversTabPanel = new JPanel();
		       {
		    	   serverPanel = new ServerPanel2(localServerManager);
		    	   serversTabPanel.add(serverPanel);
		       }
		       tabbedPane.addTab("Servers",null,serversTabPanel,null);

			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void processWindowEvent(WindowEvent e)
	{
		super.processWindowEvent(e);
		if (e.getID() == WindowEvent.WINDOW_CLOSED)
			exitAndSave();
	}

   /**
	* exitAndSave method
	* Use to:
	* handle save actions
	* @param void
	* @return void
	*/
	private void exitAndSave()
	{
		System.out.println("Exit and Save");
		accounts.save();
		groups.save();
		languageFilter.save();
		saveServerSettings();
		System.exit(0);
	}

   /**
	* createImageIcon method
	* Use to:
	* initializes a image by assigning a URL and description
	* @param path(String): indicate the URL of the image, description(String): provide the image with a discription
	* @return ImageIcon: the newly created image object
	*/
    protected static ImageIcon createImageIcon(String path, String description)
    {
        java.net.URL imgURL = Server.class.getResource(path);
        if (imgURL != null)
        {
            return new ImageIcon(imgURL, description);
        }
        else
        {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }

    /**
    * enableDiscription method
    * Use to:
	* enable the display of information for a particilar button
	* @param but(JButton): the button to which this action must be applied
	* @return void
	*/
    protected void enableDiscription(JButton button)
    {
    	button.addMouseListener(this);
    }

   /**
	* actionPerformed method
	* Use to:
	* handle action events obtained by the actionListener
	* @param ActionEvent(e): determine the type of action
	* @return void
	*/
    public void actionPerformed(ActionEvent e)
    {
    	if(e.getActionCommand().equals("accounts"))
    	{
    		accountTabPanel = new JPanel();
    		accountTabPanel.setLayout(null);
    		tabbedPane.addTab("Accounts",null,accountTabPanel,null);
    		tabbedPane.setSelectedComponent(accountTabPanel);

    		serverAccountsPanel = new ServerAccountsPanel(accounts);
    		serverAccountsPanel.setBounds(5,5,800,490);
    		accountTabPanel.add(serverAccountsPanel);

    		accountButton.setEnabled(false);
    		accountButton.removeMouseListener(this);

    		closeButton = new JButton("Close");
    		closeButton.setBounds(560,525,70,26);
            accountTabPanel.add(closeButton);

            closeButton.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent E)
                {
                    tabbedPane.remove(accountTabPanel);
                    accountButton.setEnabled(true);
                    enableDiscription(accountButton);
                }
            });
    	}

    	if(e.getActionCommand().equals("groups"))
    	{
    		groupsTabPanel = new JPanel();
    		groupsTabPanel.setLayout(null);
    		tabbedPane.addTab("Groups",null,groupsTabPanel,null);
    		tabbedPane.setSelectedComponent(groupsTabPanel);

    		groupsPanel = new GroupsPanel(groups, accounts);
    		groupsPanel.setBounds(5,5,800,490);
    		groupsTabPanel.add(groupsPanel);

    		groupButton.setEnabled(false);
    		groupButton.removeMouseListener(this);

    		closeButton = new JButton("Close");
    		closeButton.setBounds(560,525,70,26);
            groupsTabPanel.add(closeButton);

            closeButton.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent E)
                {
                    tabbedPane.remove(groupsTabPanel);
                    groupButton.setEnabled(true);
                    enableDiscription(groupButton);
                }
            });
    	}

    	if(e.getActionCommand().equals("domain"))
    	{
    		domainTabPanel = new JPanel();
    		domainTabPanel.setLayout(null);
    		tabbedPane.addTab("Domain",null,domainTabPanel,null);
    		tabbedPane.setSelectedComponent(domainTabPanel);

    		domainButton.setEnabled(false);
    		domainButton.removeMouseListener(this);

    		domainPanel = new DomainPanel(serverSettings);
    		domainPanel.setBounds(5,5,800,490);
    		domainTabPanel.add(domainPanel);

    		closeButton = new JButton("Close");
    		closeButton.setBounds(560,525,70,26);
            domainTabPanel.add(closeButton);

            closeButton.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent E)
                {
                    tabbedPane.remove(domainTabPanel);
                    domainButton.setEnabled(true);
                    enableDiscription(domainButton);
                }
            });
    	}

    	if(e.getActionCommand().equals("download"))
    	{
    		downloadTabPanel = new JPanel();
    		downloadTabPanel.setLayout(new AbsoluteLayout());
    		tabbedPane.addTab("Download",null,downloadTabPanel,null);
    		tabbedPane.setSelectedComponent(downloadTabPanel);
    		downloadgeneralPanel = new ServerGeneralPanel(ServerGeneralPanel.Images.DOWNLOADRULES);
			rulegui = new DownloadRuleGui(theRules);
			downloadgeneralPanel.add(rulegui, BorderLayout.CENTER);

            downloadTabPanel.add(downloadgeneralPanel,new AbsoluteConstraints(2,2,632,510));

    		downloadButton.setEnabled(false);
    		downloadButton.removeMouseListener(this);

    		closeButton = new JButton("Close");
    		downloadTabPanel.add(closeButton,new AbsoluteConstraints(560,525,70,26));

            closeButton.addActionListener(new ActionListener()
            {
            	public void actionPerformed(ActionEvent E)
                {
            		tabbedPane.remove(downloadTabPanel);
            		downloadButton.setEnabled(true);
                    enableDiscription(downloadButton);
                }
            });
    	}

    	if(e.getActionCommand().equals("options"))
    	{
    		optionsTabPanel = new JPanel();
    		optionsTabPanel.setLayout(new AbsoluteLayout());
    		tabbedPane.addTab("Options",null,optionsTabPanel,null);
    		tabbedPane.setSelectedComponent(optionsTabPanel);

    		optionsPanel = new OptionsPanel();
    		optionsTabPanel.add(optionsPanel,new AbsoluteConstraints(2,2,632,510));

    		optionsButton.setEnabled(false);
    		optionsButton.removeMouseListener(this);

    		closeButton = new JButton("Close");
    		optionsTabPanel.add(closeButton,new AbsoluteConstraints(560,525,70,26));

    		closeButton.addActionListener(new ActionListener()
    		{
    			public void actionPerformed(ActionEvent E)
    			{
    				tabbedPane.remove(optionsTabPanel);
    				optionsButton.setEnabled(true);
    				enableDiscription(optionsButton);
    			}
    		});
    	}

    	if(e.getActionCommand().equals("log"))
    	{
    		logTabPanel = new JPanel();
    		logTabPanel.setLayout(new AbsoluteLayout());
    		tabbedPane.addTab("Log File",null,logTabPanel,null);
    		tabbedPane.setSelectedComponent(logTabPanel);

    		logFilePanel = new LogFilePanel();
            logTabPanel.add(logFilePanel,new AbsoluteConstraints(2,2,632,510));

    		logButton.setEnabled(false);
    		logButton.removeMouseListener(this);

    		closeButton = new JButton("Close");
            logTabPanel.add(closeButton,new AbsoluteConstraints(560,525,70,26));

            closeButton.addActionListener(new ActionListener()
            {
            	public void actionPerformed(ActionEvent E)
                {
            		tabbedPane.remove(logTabPanel);
                    logButton.setEnabled(true);
                    enableDiscription(logButton);
                }
            });
    	}

    	if(e.getActionCommand().equals("languageFilter"))
    	{
    		//============= Temp=============
    		Vector<String> words = new Vector<String>();
			words.addElement("donder");
			words.addElement("moer");
			Vector<Email> emails = getTestEmails();
			//=================================

			languageFilterTabPanel = new JPanel();
    		languageFilterTabPanel.setLayout(new AbsoluteLayout());
    		tabbedPane.addTab("LanguageFilter",null,languageFilterTabPanel,null);
    		tabbedPane.setSelectedComponent(languageFilterTabPanel);
    		generalPanel = new ServerGeneralPanel(ServerGeneralPanel.Images.LANGUAGEFILTER);
    		languageFiltergui = new FilterGui(languageFilter);
			generalPanel.add(languageFiltergui, BorderLayout.CENTER);
			languageFilterTabPanel.add(generalPanel,new AbsoluteConstraints(2,2,632,510));

    		languageFilterButton.setEnabled(false);
    		languageFilterButton.removeMouseListener(this);

    		closeButton = new JButton("Close");
    		languageFilterTabPanel.add(closeButton,new AbsoluteConstraints(560,525,70,26));

            closeButton.addActionListener(new ActionListener()
            {
            	public void actionPerformed(ActionEvent E)
                {
            		tabbedPane.remove(languageFilterTabPanel);
            		languageFilterButton.setEnabled(true);
                    enableDiscription(languageFilterButton);
                }
            });
    	}

    }



	public void mouseClicked(MouseEvent me)
	{
	}

	public void mousePressed(MouseEvent me)
	{
	}

	public void mouseReleased(MouseEvent me)
	{
	}

	public void mouseEntered(MouseEvent me)
	{
		if (me.getComponent() == accountButton)
		{
			infoLabel.setText("<html><font Color=white>Modify and create new accounts</font><html>");
		}

		if (me.getComponent() == groupButton)
		{
			infoLabel.setText("<html><font Color=white>Add or remove account groups</font><html>");
		}

		if (me.getComponent() == domainButton)
		{
			infoLabel.setText("<html><font Color=white>Manage the domain settings</font><html>");
		}

		if (me.getComponent() == downloadButton)
		{
			infoLabel.setText("<html><font Color=white>Choose between different download options</font><html>");
		}

		if (me.getComponent() == optionsButton)
		{
			infoLabel.setText("<html><font Color=white>View a servers list</font><html>");
		}

		if (me.getComponent() == logButton)
		{
			infoLabel.setText("<html><font Color=white>View the Error Logs file</font><html>");
		}
		if (me.getComponent() == languageFilterButton)
		{
			infoLabel.setText("<html><font Color=white> Open the Language Filter</font><html>");
		}
	}

	public void mouseExited(MouseEvent me)
	{
		infoLabel.setText("<html><font Color=white>Move mouse over buttons for a <br> discription of their functionality</font></html>");
	}

}

⌨️ 快捷键说明

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