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

📄 addaccountpanel.java

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

import java.awt.event.ActionEvent;
import java.util.Vector;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JSplitPane;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import za.co.halo.SecureCommunications.ServerAccount;
import za.co.halo.SecureCommunications.ServerAdmin;

/**
* 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.
* *************************************
*/

/**
 * @author 
 * This class presents the GUI for adding accounts 
 * Accounts are added at the server side
 * The class ServerAccount is used to handle the accounts
 */
public class AddAccountPanel extends javax.swing.JPanel {
	private JLabel username;
	private JLabel password;
	private JPasswordField passwordText;
	private JButton saveAndCloseButton;
	private JButton cancelButton;
	private JTextField usernameText;
	private JSplitPane splitpane;
	private JList list;
	private ServerAccount accountOfClient;
	private Vector<ServerAccount> accounts;
	private String username_;
	private String password_;

   /**
	* 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 AddPOP3Account());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
   /**
	* AddAccountPanel constructor
	* Use to:
	* initialize member variables
	* initialize the build of graphical components.
	* @param JSplitPane(splitpane), Vector<ServerAccount>(accounts), JList(list) values: to initialize the member functions
	* @return void 
	*/
	public AddAccountPanel(JSplitPane splitpane, Vector<ServerAccount> accounts, JList list)
	{
		super();
		this.list = list;
		this.splitpane = splitpane;
		this.accounts = accounts;
		initGUI();
	}
	
   /**
	* initGUI method
	* Use to:
	* build the graphics
	* @param void
	* @return void 
	*/
	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(500, 258));
			this.setLayout(null);
			{
				username = new JLabel();
				this.add(username);
				username.setText("Username");
				username.setBounds(5, 5, 66, 30);
			}
			{
				usernameText = new JTextField();
				this.add(usernameText);
				username_ = usernameText.getText();
				usernameText.setBounds(120, 5, 134, 30);
			}
			{
				password = new JLabel();
				this.add(password);
				password.setText("Password");
				password.setBounds(5, 43, 60, 30);
			}
			{
				passwordText = new JPasswordField();
				this.add(passwordText);
				password_ = new String(passwordText.getPassword());
				passwordText.setBounds(120, 43, 133, 30);
			}
			{
				saveAndCloseButton = new JButton(new SaveAction());
				this.add(saveAndCloseButton);
				saveAndCloseButton.setText("Save & Close");
				saveAndCloseButton.setBounds(5, 81, 109, 26);
			}
			{
				cancelButton = new JButton(new CancelAction());
				this.add(cancelButton);
				cancelButton.setText("Cancel");
				//cancelButton.setEnabled(false);
				cancelButton.setBounds(120, 81, 73, 26);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
   /**
	* SaveAction class
	* Provides the functionality of handling save actions.
	*/
	class SaveAction extends AbstractAction {
		SaveAction() 
		{
			super("Save record");
		}

	   /**
		* actionPeformed method
		* Use to:
		* Handle save actions
		* @param ActionEvent: the type of action
		* @return void 
		*/
		public void actionPerformed(ActionEvent arg0) 
		{
			password_ = new String(passwordText.getPassword());
			username_ = usernameText.getText();
			accountOfClient = new ServerAccount(username_,password_, ServerAdmin.DEFAULT_MAX_MAILBOX_SIZE);
			accounts.addElement( accountOfClient);
			CleanPanel cleanpanel = new CleanPanel();
			splitpane.setRightComponent(cleanpanel);
			list.setListData(accounts);
		}
	}
	
   /**
	* CancelAction class
	* Provides the functionality of handling cancel actions.
	*/
	class CancelAction extends AbstractAction {
		CancelAction() {
			super("cancel creation of POP3 account");
		}

	   /**
		* actionPeformed method
		* Use to:
		* Handle cancel actions
		* @param ActionEvent: the type of action
		* @return void 
		*/
		public void actionPerformed(ActionEvent arg0) 
		{
			CleanPanel cleanpanel = new CleanPanel();
			splitpane.setRightComponent(cleanpanel);
			
		}

	}
}

⌨️ 快捷键说明

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