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

📄 addgrouppanel.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.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import za.co.halo.SecureCommunications.ServerAccount;
import za.co.halo.SecureCommunications.ServerManager;
import za.co.halo.SecureCommunications.ServerGroup;
/**
 * @author 
 * This class presents the GUI for adding groups
 * Groups are added at the server side
 * The class ServerGroup is used to handle the 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 AddGroupPanel extends javax.swing.JPanel {
	private JLabel groupname;
	private JLabel accountsLabel;
	private JScrollPane scrollPane;
	private JTextField groupnameText;
	private JButton saveAndCloseButton;
	private JButton cancelButton;
	private JSplitPane splitpane;
	private JList list;
	private JList accountList;
	private ServerGroup groupOfClient;
	private Vector<ServerGroup> groups;
	private String groupname_;
	private ServerManager accounts;

   /**
	* The 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);
	}
	
   /**
	* The AddGroupPanel constructor
	* Use to
	* initialize member variables
	* initialize the build of graphical components
	* @param splitpane, accounts: to initialize the member functions
	* @return void 
	*/
	public AddGroupPanel(JSplitPane splitpane, Vector<ServerGroup> groups, ServerManager accounts, JList list)
	{
		super();
		this.splitpane = splitpane;
		this.accounts = accounts;
		this.groups = groups;
		this.list = list;
		initGUI();
	}
	
  /**
	* initGUI method
	* Use to:
	* initialize the graphics
	* @param void
	* @return void 
	*/
	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(500, 330));
			this.setLayout(null);
			{
				groupname = new JLabel();
				this.add(groupname);
				groupname.setText("Groupname");
				groupname.setBounds(5, 5, 79, 30);
			}
			{
				groupnameText = new JTextField();
				this.add(groupnameText);
				groupname_ = groupnameText.getText();
				groupnameText.setBounds(80, 5, 180, 30);
			}
			{
				accountsLabel = new JLabel();
				this.add(accountsLabel);
				accountsLabel.setText("Choose Applicable Accounts");
				accountsLabel.setBounds(5, 50, 165, 30);
				
			}
			{
				saveAndCloseButton = new JButton(new SaveAction());
				this.add(saveAndCloseButton);
				saveAndCloseButton.setText("Save & Close");
				saveAndCloseButton.setBounds(5, 300, 109, 26);
			}
			{
				cancelButton = new JButton(new CancelAction());
				this.add(cancelButton);
				cancelButton.setText("Cancel");
				cancelButton.setBounds(120, 300, 73, 26);
			}
			{
				accountList = new JList(accounts.getAccounts());
				scrollPane = new JScrollPane(accountList);
				scrollPane.setBounds(10,80,250,200);
				this.add(scrollPane);
			}
		} 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) 
		{
			groupname_ = groupnameText.getText();
			groupOfClient = new ServerGroup(groupname_);
			Object[] ob = accountList.getSelectedValues();
			for (int i=0; i<ob.length; i++)
			{
				if (ob[i] instanceof ServerAccount)
				{
					groupOfClient.addAccount((ServerAccount)(ob[i]));
					System.out.println(ob[i]);
				}
			}
			groups.addElement(groupOfClient);
			CleanPanel cleanpanel = new CleanPanel();
			splitpane.setRightComponent(cleanpanel);
			list.setListData(groups);
			System.out.println(groupOfClient.getAccounts());
		}
	}
	
   /**
	* CancelAction class
	* Provides the functionality of handling cancel actions.
	*/
	class CancelAction extends AbstractAction {
		CancelAction() {
			super("canceled creation of group");
		}

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