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

📄 serverviewaccountpanel.java

📁 create the email in the server
💻 JAVA
字号:
package za.co.halo.SecureCommunications.gui.server;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Vector;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
import javax.swing.text.html.StyleSheet;

//import za.co.halo.SecureCommunications.AccountOfClient;
import za.co.halo.SecureCommunications.Email;
import za.co.halo.SecureCommunications.ServerAccount;
/**
 * @author
 * ServerViewAccountPanel class
 * This class presents the GUI for viewing and editing accounts
 */

/**
* This code was 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 ServerViewAccountPanel extends javax.swing.JPanel {

	private static final long serialVersionUID = 1L;
	private JList emailList;
	public JSplitPane splitpane2;
	private ServerAccountsPanel accountspanel;
	private int localindex;
	private Vector<ServerAccount> accounts;
	

   /**
	* main method
	* Use to:
	* display this JPanel inside a new JFrame
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		//frame.getContentPane().add(new EmailPanel(null,null));
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
   /**
	* ServerAccountPanel constructor
	* Use to:
	* initialize member variables
	* initialize the build of graphical components.
	* @param Vector<ServerAccounts>(accounts), JSplitPane(splitpane_), ServerAccountsPanel(accountsPanel): to initialize the member functions
	* @return void 
	*/
	public ServerViewAccountPanel(Vector<ServerAccount> accounts, JSplitPane splitpane_ , ServerAccountsPanel accountspanel) 
	{
		super();
//		client = c;
//		client.emailselected = c.emailselected;
		splitpane2 = splitpane_;
		this.accountspanel = accountspanel;
//		this.leftpanel = leftpanel;
		//this.cancel = cancel;
		//this.save = save;
//		this.emails = email;
		this.accounts = accounts;
		initGUI();
	}
	
   /**
	* initGUI method
	* Use to:
	* build the graphics
	* @param void
	* @return void 
	*/
	private void initGUI() {
		try {
			BorderLayout thisLayout = new BorderLayout();
			this.setLayout(thisLayout);
			setPreferredSize(new Dimension(200, 300));
			{
				{
					emailList = new JList(accounts);
					emailList.setBackground(new Color(21,118,146));
					this.add(emailList, BorderLayout.CENTER);
					
					emailList.setCellRenderer(new EmailCellRenderer());
					emailList.setPreferredSize(new java.awt.Dimension(388, 181));
					emailList.setSize(200,300);
					MouseListener mouseListener = new MouseAdapter() {
					     public void mouseClicked(MouseEvent e/*, ComposeMail composeMail*/) {
					    	if (e.getClickCount() == 2) 
					         {
					            
					           					        
					         } 
					    	 if (e.getClickCount() == 1) 
					         {
					    		   accountspanel.removeButton.setEnabled(true);
					    		   int index = emailList.locationToIndex(e.getPoint());
					    		   if (index != -1)
					    		   {
					    			   ServerAccount account = accounts.get(index);
							           localindex = index;
							           SingleViewAccountPanel panel = new SingleViewAccountPanel(account, index,accounts,splitpane2);
							           splitpane2.setRightComponent(panel);
							           //TODO: Open right tab to change settings
/*							           if(account.getType() == AccountOfClient.Types.POPSMTP)
							           {
							            	SingelPOP3ViewPanel pop3panel=  new SingelPOP3ViewPanel(email , localindex ,accounts , splitpane2);
							            	splitpane2.setRightComponent(pop3panel);
							           }
							           else if(email.getType() == AccountOfClient.Types.RMI)
							           {
							                SingleRMIViewPanel rmipanel=  new SingleRMIViewPanel(email,  localindex, accounts , splitpane2);
							                  splitpane2.setRightComponent(rmipanel);
							           }*/
					    		   }
					         }
					     }
					 };
					 emailList.addMouseListener(mouseListener);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
    class Hyperactive implements HyperlinkListener {
    	 
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane pane = (JEditorPane) e.getSource();
                if (e instanceof HTMLFrameHyperlinkEvent) {
                    HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
                    HTMLDocument doc = (HTMLDocument)pane.getDocument();
                    doc.processHTMLFrameHyperlinkEvent(evt);
                } else {
                    try {
                        pane.setPage(e.getURL());
                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            }
        }
    }

	
	class EmailCellRenderer implements ListCellRenderer
	{
		public Component getListCellRendererComponent(JList list, Object object, int index, boolean isSelected, boolean arg4) 
		{
			JPanel panel = new JPanel();
			panel.setSize(150,20);
			if (object instanceof ServerAccount)
			{
				ServerAccount e = (ServerAccount)object;
				panel.setLayout(new BorderLayout());
				panel.add(new SingelAccountClass(e, isSelected ));
				//account = e;
			}
			else 
				panel.add(new JLabel("Could not load information"));
			return panel;
		}
	}
	
	class ViewEmailEditorPane extends JEditorPane
	{
		public ViewEmailEditorPane()
		{
			
			HTMLEditorKit kit = new HTMLEditorKit();
            StyleSheet style = new StyleSheet();
            try {
           	 File f = new File("emailstylesheet.css");
           	 
				style.importStyleSheet(f.toURL());
			      } 
            catch (MalformedURLException e1) 
            {
				e1.printStackTrace();
			 }
            kit.setStyleSheet(style);
            setEditorKit(kit);

		}
		
		public void setText(Email e)
		{
           
       }
	
	}
	
/*	public AccountOfClient getInfo()
	{
		return email;
	}*/
	public int getIndex()
	{
		return localindex;
	}
	// @depricated
	public JList getList()
	{
		return emailList;
	}
}
		
		

⌨️ 快捷键说明

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