📄 serveraccountspanel.java
字号:
package za.co.halo.SecureCommunications.gui.server;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.AbstractAction;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
import za.co.halo.SecureCommunications.Email;
import za.co.halo.SecureCommunications.ServerAccount;
import za.co.halo.SecureCommunications.ServerManager;
/**
* @author
* ServerAccountsPanel class
* This class presents the GUI for handling accounts
* The actions of adding or removing a account are available
* The ServerViewAccountsPanel class are used by the ServerAccountsPanel which represent a way of
* managing 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 ServerAccountsPanel extends javax.swing.JPanel {
private ImagePanel imagePanel;
public JSplitPane splitpane;
public JEditorPane leftEditorpane;
public JPanel leftButtonPanel;
public JButton removeButton;
private JButton AddButton;
public JPanel rightButtonPanel;
public JPanel rightPanel;
public ServerViewAccountPanel panel;
int index = 0;
public Vector<ServerAccount> vectorOfAccount;
private JList list;
/**
* main method
* Use to:
* display this JPanel inside a new JFrame.
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
//ServerManager accounts = getTestAccount();
//frame.getContentPane().add(new ServerAccountsPanel(accounts));
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
/**
* ServerAccountsGroupPanel constructor
* Use to:
* initialize member variables
* initialize the build of graphical components.
* @param ServerManager(accounts): initialize the member function
* @return void
*/
public ServerAccountsPanel(ServerManager accounts)
{
super();
System.out.println("Opened ServerAccountsPanel");
//this.list = list;
//accountPanel = this;
//this.generalPanel = generalPanel;
//client = c;
vectorOfAccount = accounts.getAccounts();
initGUI();
}
/**
* initGUI method
* Use to:
* initialize graphics
* @param void
* @return void
*/
private void initGUI() {
try {
setPreferredSize(new Dimension(600,500));
//Vector<AccountOfClient> clients = vectorOfAccount;
//clients = vectorOfAccount;
this.setLayout(null);
{
imagePanel = new ImagePanel("images/accounts.png","accounts");
imagePanel.setLayout(null);
imagePanel.setBounds(0,0,625,83);
this.add(imagePanel);
splitpane = new JSplitPane();
this.add(splitpane);
splitpane.setPreferredSize(new java.awt.Dimension(600, 333));
splitpane.setBounds(7, 100, 600, 333);
{
//Client client = cl;
panel = new ServerViewAccountPanel(vectorOfAccount,splitpane, this);
list = panel.getList();
panel.setSize(200, 300);
panel.setMinimumSize(new Dimension(300,300));
splitpane.add(panel, JSplitPane.LEFT);
}
{
rightPanel = new JPanel();
splitpane.add(rightPanel, JSplitPane.RIGHT);
rightPanel.setPreferredSize(new java.awt.Dimension(154, 331));
}
}
{
leftButtonPanel = new JPanel();
this.add(leftButtonPanel);
leftButtonPanel.setPreferredSize(new java.awt.Dimension(183, 52));
leftButtonPanel.setLayout(null);
leftButtonPanel.setBounds(13, 442, 305, 52);
{
AddButton = new JButton(new AddAction());
leftButtonPanel.add(AddButton);
AddButton.setText("Add Account");
AddButton.setPreferredSize(new java.awt.Dimension(102, 26));
AddButton.setBounds(3, 1, 143, 26);
}
{
removeButton = new JButton(new RemoveAction());
leftButtonPanel.add(removeButton );
removeButton.setText("Remove Account");
removeButton.setEnabled(false);
removeButton.setPreferredSize(new java.awt.Dimension(96, 26));
removeButton.setBounds(152, 1, 143, 26);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* AddAction class
* Provides the functionality of handling add actions.
*/
class AddAction extends AbstractAction {
private AddAccountPanel addAccountPanel;
AddAction()
{
super("Add account");
}
/**
* actionPeformed method
* Use to:
* Handle add actions
* @param ActionEvent(arg0): the type of action
* @return void
*/
public void actionPerformed(ActionEvent arg0)
{
addAccountPanel = new AddAccountPanel(splitpane, vectorOfAccount, list);
splitpane.add(addAccountPanel, JSplitPane.RIGHT);
}
}
/**
* RemoveAction class
* Provides the functionality of handling remove actions.
*/
class RemoveAction extends AbstractAction {
RemoveAction() {
super("Cancel creation of RMI account");
}
/**
* actionPeformed method
* Use to:
* Handle remove actions
* @param ActionEvent(arg0): the type of action
* @return void
*/
public void actionPerformed(ActionEvent arg0)
{
//client.accounts.remove(index);
//AccountOfClient clientToRemove = panel.getInfo();
int indexToRemove = panel.getIndex();
vectorOfAccount.remove(indexToRemove);
splitpane.setRightComponent(new CleanPanel());
panel.repaint();
}
}
/*public Vector<AccountOfClient> getNewVector()
{
return vectorOfAccount;
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -