📄 showaccountspanel.java
字号:
package za.co.halo.SecureCommunications.gui.server;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.util.Vector;
import za.co.halo.SecureCommunications.ErrorReporting;
/**
* 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 ShowAccountsPanel extends javax.swing.JPanel implements ActionListener
{
private JScrollPane scrollable;
private JPanel accountsViewPanel;
private JPanel accountsLabelPanel;
private JList accountList;
private DefaultListModel listModel;
//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);
/**
* 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 ShowAccountsPanel());
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public ShowAccountsPanel()
{
super();
initGUI();
}
private void initGUI()
{
try
{
//this.setLayout(null);
//setBounds(5,5,485,480);
this.setPreferredSize(new Dimension(490, 480));
//setBackground(new Color(21,118,146));
addWidgets();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void addWidgets()
{
accountsLabelPanel = new JPanel();
//accountsLabelPanel.setLayout(null);
//accountsLabelPanel.setBounds(0,0,487,480);
accountsLabelPanel.setPreferredSize(new Dimension(490, 477));
accountsLabelPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Accounts"),BorderFactory.createEmptyBorder(0,0,0,0)));
this.add(accountsLabelPanel);
//accountsViewPanel = new JPanel();
//accountsViewPanel.setBackground(new Color(21,118,146));
//accountsViewPanel.setLayout(null);
//accountsViewPanel.setBounds(0,0,476,458);
//accountsViewPanel.setPreferredSize(new Dimension(480,440));
//listModel = new DefaultListModel();
//listModel.addElement("Element");
Vector<Account> v = new Vector();
AccountsManager man = new AccountsManager(v);
man.load();
listModel = new DefaultListModel();
for(int i = 0; i < man.getNumberOfAccounts(); i++)
{
Account element = man.getAccount(i);
listModel.addElement(element.getFirstName()+""+element.getLastName());
}
accountList = new JList(listModel);
//accountList.setPreferredSize(new Dimension(470,430));
accountList.setBackground(new Color(21,118,146));
accountList.setForeground(Color.white);
accountList.setSelectionBackground(new Color(15,65,108));
accountList.setSelectionForeground(Color.white);
//**accountList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
//**accountList.setLayout(null);
//**accountList.setBounds(0,0,20,20);
//accountsViewPanel.add(accountList);
scrollable = new JScrollPane(accountList);
scrollable.setPreferredSize(new Dimension(483, 448));
//scrollable.add(accountsViewPanel);
//**scrollable.setLayout(null);
//**scrollable.setBounds(5,15,478,460);
accountsLabelPanel.add(scrollable);
/*viewPanel = new JPanel();
viewPanel.setLayout(null);
viewPanel.setBounds(3,3,480,480);
viewPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Accounts"),BorderFactory.createEmptyBorder(0,0,0,0)));
this.add(viewPanel);*/
//displayAccount(man.getAccount(place));
}
public void displayAccount(Account a)
{
/*//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 viewAccountsButton = new JButton("Edit");
viewAccountsButton.setBounds(50,440,80,26);
viewAccountsButton.setActionCommand("Edit");
viewPanel.add(viewAccountsButton);
viewAccountsButton.addActionListener(this);
JButton removeAccountButton = new JButton("Remove");
removeAccountButton.setBounds(135,440,80,26);
removeAccountButton.setActionCommand("remove");
removeAccountButton.addActionListener(this);
viewPanel.add(removeAccountButton);
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("next"))
{
man.load();
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 + -