1 package org.wcb.gui.dialog;
2
3 import org.wcb.gui.forms.auth.JLoginUpdatePanel;
4 import org.wcb.gui.util.UIHelper;
5
6 import javax.swing.*;
7 import java.awt.event.ActionListener;
8 import java.awt.event.ActionEvent;
9 import java.awt.*;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class JLoginUpdateUserDialog extends JDialog implements ActionListener {
37
38 private JLoginUpdatePanel panel;
39 private JButton loginButton;
40 private JButton cancelButton;
41
42 public JLoginUpdateUserDialog() {
43 super();
44 init();
45 }
46
47 public JLoginUpdateUserDialog(Frame owner) {
48 super(owner);
49 init();
50 }
51
52 public JLoginUpdateUserDialog(Frame owner, boolean modal) throws HeadlessException {
53 super(owner, modal);
54 init();
55 }
56
57 public JLoginUpdateUserDialog(Frame owner, String title) throws HeadlessException {
58 super(owner, title);
59 init();
60 }
61
62 public JLoginUpdateUserDialog(Frame owner, String title, boolean modal)
63 throws HeadlessException {
64 super(owner, title, modal);
65 init();
66 }
67
68 protected void init() {
69 setLayout(new BorderLayout());
70 setPanel(new JLoginUpdatePanel());
71 add(createButtonPanel(), BorderLayout.SOUTH);
72 pack();
73 }
74
75 private JPanel createButtonPanel() {
76 loginButton = new JButton("Update");
77 cancelButton = new JButton("Cancel");
78 loginButton.addActionListener(this);
79 cancelButton.addActionListener(this);
80
81 JPanel buttonPanel = new JPanel(new GridBagLayout());
82 buttonPanel.add(loginButton, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(17, 12, 11, 5), 0, 0));
83 buttonPanel.add(cancelButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(17, 0, 11, 11), 0, 0));
84 return buttonPanel;
85 }
86
87 public JLoginUpdatePanel getPanel() {
88 return panel;
89 }
90
91 public void setPanel(JLoginUpdatePanel panel) {
92 this.panel = panel;
93 add(this.panel, BorderLayout.NORTH);
94 UIHelper.centerDialogToScreen(this);
95 }
96
97
98 public void actionPerformed(ActionEvent evt) {
99 Object src = evt.getSource();
100 if(src.equals(loginButton)) {
101 boolean show = getPanel().updateUser();
102 if(show) {
103 this.dispose();
104 }
105 }
106 if(src.equals(cancelButton)) {
107 this.dispose();
108 }
109 }
110
111 }