private void display() { if (vo == null) { nameField.setText(""); moneyField.setText(""); } else { nameField.setText(vo.getAccountname()); moneyField.setText(Double.toString(vo.getAccountsum())); } }
private void initComponents() { if (opr.equals("search")) { nameLabel = new JLabel("关键字:"); nameLabel.setBounds(25, 45, 50, 15); nameField = new JTextField(); nameField.setBounds(100, 40, 175, 25); this.getContentPane().add(nameLabel); this.getContentPane().add(nameField); } else { nameLabel = new JLabel("账户名:"); nameLabel.setBounds(25, 25, 50, 15); idLabel = new JLabel("账号:"); idLabel.setBounds(25, 75, 50, 15); nameField = new JTextField(); nameField.setBounds(100, 20, 175, 25); idField = new JTextField(); idField.setBounds(100, 70, 175, 25); if (opr.equals("update")) { nameField.setText(vo.getName()); idField.setText(vo.getAccountID()); idField.setEditable(false); } this.getContentPane().add(nameLabel); this.getContentPane().add(idLabel); this.getContentPane().add(nameField); this.getContentPane().add(idField); } okBtn = new JButton("确定"); okBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (opr.equals("add")) { try { String result = ui.getController().addAccount(getName(), getID()); if (result != null) { JOptionPane.showMessageDialog(null, result, "", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(null, "添加成功", "", JOptionPane.INFORMATION_MESSAGE); } ui.initList(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } if (opr.equals("update")) { try { String result = ui.getController().modifyAccount(vo, getName()); if (result != null) { JOptionPane.showMessageDialog(null, result, "", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(null, "修改成功", "", JOptionPane.INFORMATION_MESSAGE); } ui.initList(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } if (opr.equals("search")) { List<AccountVO> list = ui.getController().searchAccount(getName()); ui.initList(list); } setVisible(false); } }); okBtn.setBounds(50, 120, 75, 30); this.getContentPane().add(okBtn); returnBtn = new JButton("返回"); returnBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); returnBtn.setBounds(175, 120, 75, 30); this.getContentPane().add(returnBtn); }
@Override public int compareTo(AccountVO o) { return this.getAccountNumber().compareTo(o.getAccountNumber()); }