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

📄 addaccountpanel2.java

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

import javax.swing.*;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;




/**
* 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 AddAccountPanel2 extends javax.swing.JPanel implements ActionListener
{
	private JPanel viewPanel;
	private JLabel firstNameLabel = new JLabel();
	private JLabel lastNameLabel = new JLabel();
	private JLabel userNameLabel = new JLabel();
	private JLabel emailAddressLabel = new JLabel();
	private JLabel accountTypeLabel = new JLabel();
	private JTextArea firstNameText = new JTextArea();
	private JTextArea lastNameText = new JTextArea();
	private JTextArea userNameText = new JTextArea();
	private JTextArea emailAddressText = new JTextArea();
	private JTextArea accountTypeText = new JTextArea();
	private int place = 0;
	
	private Vector<Account> v = new Vector();
	private AccountsManager man = new AccountsManager(v);
	private Account elementAccount;
	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) 
	{
		JFrame frame = new JFrame();
		frame.getContentPane().add(new AddAccountPanel2());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public AddAccountPanel2() 
	{
		super();
		initGUI();
	}
	
	private void initGUI() 
	{
		try 
		{
			this.setLayout(null);
			setBounds(2,2,500,490);
			addWidgets();
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		}
	}
	
	private void addWidgets()
	{
		viewPanel = new JPanel();
		viewPanel.setLayout(null);
		viewPanel.setBounds(3,3,480,480);
		viewPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Add Accounts"),BorderFactory.createEmptyBorder(0,0,0,0)));
		this.add(viewPanel);
		
		Vector<Account> v = new Vector();
		AccountsManager man = new AccountsManager(v);
		
		man.load();
		
		displayForm();
		
	}
	
	public void displayForm()
	{
		//firstNameLabel = new JLabel("First name:");
		firstNameLabel.setText("First name:");
		firstNameLabel.setBounds(40,30,100,30);
		viewPanel.add(firstNameLabel);
		//lastNameLabel = new JLabel("Last name:");
		lastNameLabel.setText("Last name:");
		lastNameLabel.setBounds(40,70,100,30);
		viewPanel.add(lastNameLabel);
		userNameLabel.setText("User name:");
		//userNameLabel = new JLabel("User name:");
		userNameLabel.setBounds(40,110,100,30);
		viewPanel.add(userNameLabel);
		emailAddressLabel.setText("Email Address:");
		//emailAddressLabel = new JLabel("Email Address:");
		emailAddressLabel.setBounds(40,150,100,30);
		viewPanel.add(emailAddressLabel);
		accountTypeLabel.setText("Account Type:");
		//accountTypeLabel = new JLabel("Account Type:");
		accountTypeLabel.setBounds(40,190,100,30);
		//viewPanel.add(accountTypeLabel);
		
		//firstNameText = new JTextArea(a.getFirstName());
		//firstNameText.setText(a.getFirstName());
		//firstNameText.setEditable(false);
		firstNameText.setBounds(170,30,200,30);
		viewPanel.add(firstNameText);
		//lastNameText = new JTextArea(a.getLastName());
		//lastNameText.setText(a.getLastName());
		//lastNameText.setEditable(false);
		lastNameText.setBounds(170,70,200,30);
		viewPanel.add(lastNameText);
		//userNameText = new JTextArea(a.getUserName());
		//userNameText.setText(a.getUserName());
		//userNameText.setEditable(false);
		userNameText.setBounds(170,110,200,30);
		viewPanel.add(userNameText);
		//emailAddressText = new JTextArea(a.getEmailAddress());
		//emailAddressText.setText(a.getEmailAddress());
		//emailAddressText.setEditable(false);
		emailAddressText.setBounds(170,150,200,30);
		viewPanel.add(emailAddressText);
		//accountTypeText = new JTextArea(a.getAccountType());
		//accountTypeText.setText(a.getAccountType());
		//accountTypeText.setEditable(false);
		//accountTypeText.setBounds(170,190,200,30);
		//viewPanel.add(accountTypeText);
		
		viewPanel.repaint();
		addButtons();
	}
	
	public void addButtons()
    {	
		JButton saveButton = new JButton("Save");
		saveButton.setBounds(50,440,80,26);
		saveButton.setActionCommand("save");
		viewPanel.add(saveButton);
		saveButton.addActionListener(this);
		
		JButton cancelButton = new JButton("Cancel");
		cancelButton.setBounds(135,440,80,26);
		cancelButton.setActionCommand("cancel");
		cancelButton.addActionListener(this);
		viewPanel.add(cancelButton);
		
		/*JButton prevAccountsButton = new JButton("<<");
		prevAccountsButton.setBounds(240,440,50,26);
		prevAccountsButton.setActionCommand("prev");
		prevAccountsButton.addActionListener(this);
		viewPanel.add(prevAccountsButton);
		
		JButton nextAccountsButton = new JButton(">>");
		nextAccountsButton.setBounds(295,440,50,26);
		nextAccountsButton.setActionCommand("next");
		nextAccountsButton.addActionListener(this);
		viewPanel.add(nextAccountsButton);
		/*JButton editAccountsButton = new JButton("Edit / Remove Accounts");
		editAccountsButton.setBounds(243,2,167,26);
		buttonPanel.add(editAccountsButton);*/
    }
	
	public void actionPerformed(ActionEvent e)
	{
		if (e.getActionCommand().equals("save"))
		{
			man.load();
			String fname = firstNameText.getText();
			String lname = lastNameText.getText();
			String uname = userNameText.getText();
			String email = userNameText.getText();
			
			elementAccount = new Account(fname,lname,uname,"",email);
			man.addAccount(elementAccount);
			man.save();
			//System.out.println(fname + ' ' + lname + ' ' + uname + ' ' + email);
			/*if(place < man.getNumberOfAccounts()-1)
			{
				place++;
				displayAccount(man.getAccount(place));
			}*/
		}
		
		/*if (e.getActionCommand().equals("prev"))
		{
			if(place > 0)
			{
				place--;
				displayAccount(man.getAccount(place));
			}
		}
		
		if (e.getActionCommand().equals("remove"))
		{
			man.load();
			man.removeAccount(man.getAccount(place));
			man.save();
			man.load();
			
		}*/
	}

}


⌨️ 快捷键说明

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