1 | package genius.gui.domainrepository;
|
---|
2 |
|
---|
3 | import java.awt.Frame;
|
---|
4 | import java.awt.event.ActionEvent;
|
---|
5 | import java.awt.event.ActionListener;
|
---|
6 | import javax.swing.JButton;
|
---|
7 | import javax.swing.JDialog;
|
---|
8 | import javax.swing.JLabel;
|
---|
9 | import javax.swing.JOptionPane;
|
---|
10 | import javax.swing.JTextField;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * GUI used to createFrom a new domain.
|
---|
14 | *
|
---|
15 | * @author Mark Hendrikx
|
---|
16 | */
|
---|
17 | public class CreateNewDomain extends JDialog {
|
---|
18 |
|
---|
19 | private JButton okButton;
|
---|
20 | private JButton cancelButton;
|
---|
21 | private JLabel domainNameLabel;
|
---|
22 | private JTextField domainNameField;
|
---|
23 | private String result = null;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Creates new form DomainCreationUI
|
---|
27 | */
|
---|
28 | public CreateNewDomain(Frame frame) {
|
---|
29 | super(frame, "Create domain", true);
|
---|
30 | this.setLocation(frame.getLocation().x + frame.getWidth() / 4, frame.getLocation().y + frame.getHeight() / 4);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public String getResult() {
|
---|
34 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
---|
35 | setResizable(false);
|
---|
36 | getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
|
---|
37 |
|
---|
38 | domainNameLabel = new JLabel();
|
---|
39 | okButton = new JButton();
|
---|
40 | cancelButton = new JButton();
|
---|
41 | domainNameField = new JTextField();
|
---|
42 |
|
---|
43 | domainNameLabel.setText("Domain name");
|
---|
44 |
|
---|
45 | okButton.setText("Ok");
|
---|
46 | okButton.addActionListener(new ActionListener() {
|
---|
47 | public void actionPerformed(ActionEvent e) {
|
---|
48 | if (domainNameField.getText().equals("")) {
|
---|
49 | JOptionPane.showMessageDialog(null, "The domain name may not be empty.", "Parameter error", 0);
|
---|
50 | } else {
|
---|
51 | result = domainNameField.getText();
|
---|
52 | dispose();
|
---|
53 | }
|
---|
54 | }
|
---|
55 | });
|
---|
56 |
|
---|
57 | cancelButton.setText("Cancel");
|
---|
58 | cancelButton.addActionListener(new ActionListener() {
|
---|
59 | public void actionPerformed(ActionEvent e) {
|
---|
60 | dispose();
|
---|
61 | }
|
---|
62 | });
|
---|
63 |
|
---|
64 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
---|
65 | getContentPane().setLayout(layout);
|
---|
66 | layout.setHorizontalGroup(
|
---|
67 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
---|
68 | .addGroup(layout.createSequentialGroup()
|
---|
69 | .addContainerGap()
|
---|
70 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
---|
71 | .addGroup(layout.createSequentialGroup()
|
---|
72 | .addComponent(domainNameLabel)
|
---|
73 | .addGap(74, 74, 74)
|
---|
74 | .addComponent(domainNameField))
|
---|
75 | .addGroup(layout.createSequentialGroup()
|
---|
76 | .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
---|
77 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
---|
78 | .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
---|
79 | .addGap(0, 133, Short.MAX_VALUE)))
|
---|
80 | .addContainerGap())
|
---|
81 | );
|
---|
82 | layout.setVerticalGroup(
|
---|
83 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
---|
84 | .addGroup(layout.createSequentialGroup()
|
---|
85 | .addContainerGap()
|
---|
86 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
---|
87 | .addComponent(domainNameLabel)
|
---|
88 | .addComponent(domainNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
---|
89 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
---|
90 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
---|
91 | .addComponent(okButton)
|
---|
92 | .addComponent(cancelButton))
|
---|
93 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
---|
94 | );
|
---|
95 |
|
---|
96 | pack();
|
---|
97 | setVisible(true);
|
---|
98 | return result;
|
---|
99 | }
|
---|
100 | } |
---|