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

📄 viewaccountpanell.java

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

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.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
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.ClientAccountManager;
import za.co.halo.SecureCommunications.Email;


/**
* 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 ViewAccountPanell extends javax.swing.JPanel {

	private static final long serialVersionUID = 1L;
	private JList emailList;
	public Client client;
	private  AccountOfClient email;
	public JSplitPane splitpane2;
	private AccountsPanel accountspanel;
	private int localindex;
	private ClientAccountManager accounts;
	

	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public ViewAccountPanell(ClientAccountManager accounts, JSplitPane splitpane_ , AccountsPanel accountspanel) 
	{
		super();
		splitpane2 = splitpane_;
		this.accountspanel = accountspanel;
		this.accounts = accounts;
		initGUI();
	}
	
	private void initGUI() {
		try {
			BorderLayout thisLayout = new BorderLayout();
			this.setLayout(thisLayout);
			setPreferredSize(new Dimension(200,100));
			{
				{
					
					emailList = new JList(accounts.getAccounts());
					emailList.setBackground(new Color(21,118,146));
					JScrollPane scrollPane = new JScrollPane(emailList);
					emailList.setCellRenderer(new AccountCellRenderer());
					emailList.setPreferredSize(new java.awt.Dimension(388, 181));
					emailList.setSize(200,300);
					this.add(scrollPane, BorderLayout.CENTER);
					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)
					    		   {
							           email = accounts.getAccount(index);
							           localindex = index;
							           if(email.getType() == AccountOfClient.Types.POPSMTP)
							           {
							            	SingelPOP3ViewPanel pop3panel=  new SingelPOP3ViewPanel(email , localindex ,accounts.getAccounts() , splitpane2);
							            	splitpane2.setRightComponent(pop3panel);
							            	splitpane2.setDividerLocation(0.5);
							            	accountspanel.rightPanel.setSize(300,300);
							              
							           }
							           else if(email.getType() == AccountOfClient.Types.RMI)
							           {
							                SingleRMIViewPanel rmipanel=  new SingleRMIViewPanel(email,  localindex, accounts.getAccounts() , splitpane2);
							               
							                splitpane2.setRightComponent(rmipanel);
							                splitpane2.setDividerLocation(0.5);
							               
							           }
					    		   }
					         }
					     }
					 };
					 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 AccountCellRenderer 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 AccountOfClient)
			{
				AccountOfClient e = (AccountOfClient)object;
				panel.setLayout(new BorderLayout());
				boolean isDefault = false;
				if (e == accounts.getDefaultAccount())
					isDefault = true;
				System.out.println(e.getEmailAddress()+" = "+(accounts.getDefaultAccount()==null?"null":accounts.getDefaultAccount().getEmailAddress())+" == "+isDefault);
				SingelAccountClass singleAccount = new SingelAccountClass(e, isSelected ,isDefault);
				panel.add(singleAccount);
			}
			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 + -