Container contentPane = this.getContentPane();
contentPane.removeAll();
contentPane.setLayout(new FlowLayout());
Wallet wallet = UIEthereumManager.ethereum.getWallet();
for (Account account : wallet.getAccountCollection()) {
WalletAddressPanel rowPanel = new WalletAddressPanel(account);
contentPane.add(rowPanel);
}
WalletSumPanel sumPanel = new WalletSumPanel(wallet.totalBalance());
contentPane.add(sumPanel);
// TODO: move this to some add button method
URL addAddressIconURL = ClassLoader.getSystemResource("buttons/add-address.png");
ImageIcon addAddressIcon = new ImageIcon(addAddressIconURL);
JLabel addAddressLabel = new JLabel(addAddressIcon);
addAddressLabel.setToolTipText("Add new address");
addAddressLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
addAddressLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Wallet wallet = UIEthereumManager.ethereum.getWallet();
if (wallet.getAccountCollection().size() >= 5) {
JOptionPane.showMessageDialog(walletWindow,
"Hey do you really need more than 5 address for a demo wallet");
return;
}
wallet.addNewAccount();
Dimension dimension = walletWindow.getSize();
int height = dimension.height;
int width = dimension.width;
Dimension newDimension = new Dimension(width, (height + 45));