01: package com.xoetrope.carousel.services.dialog;
02:
03: import java.awt.BorderLayout;
04: import java.awt.GridLayout;
05: import java.awt.event.ActionEvent;
06: import java.awt.event.ActionListener;
07: import javax.swing.JButton;
08: import javax.swing.JDialog;
09: import javax.swing.JLabel;
10: import javax.swing.JPanel;
11: import javax.swing.JTextField;
12:
13: /**
14: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
15: * the GNU Public License (GPL), please see license.txt for more details. If
16: * you make commercial use of this software you must purchase a commercial
17: * license from Xoetrope.</p>
18: * <p> $Revision: 1.3 $</p>
19: */
20: public class DatabaseConnector extends JDialog implements
21: ActionListener {
22: private JTextField txtURL, txtUserID, txtPassword;
23: private JPanel mainPanel;
24: private JButton btnOK, btnCancel;
25:
26: private boolean isOK = false;
27:
28: public DatabaseConnector() {
29: setSize(300, 150);
30: setModal(true);
31: getContentPane().setLayout(new BorderLayout());
32: createComponents();
33: }
34:
35: private void createComponents() {
36: mainPanel = new JPanel(new GridLayout(4, 2));
37: txtURL = new JTextField();
38: txtUserID = new JTextField();
39: txtPassword = new JTextField();
40: btnOK = new JButton("OK");
41: btnCancel = new JButton("Cancel");
42: btnOK.addActionListener(this );
43: btnCancel.addActionListener(this );
44:
45: mainPanel.add(new JLabel("URL:"));
46: mainPanel.add(txtURL);
47: mainPanel.add(new JLabel("User ID:"));
48: mainPanel.add(txtUserID);
49: mainPanel.add(new JLabel("Password:"));
50: mainPanel.add(txtPassword);
51: mainPanel.add(btnOK);
52: mainPanel.add(btnCancel);
53:
54: getContentPane().add(mainPanel, BorderLayout.CENTER);
55: }
56:
57: public String getURL() {
58: return txtURL.getText();
59: }
60:
61: public String getUserID() {
62: return txtUserID.getText();
63: }
64:
65: public String getPassword() {
66: return txtPassword.getText();
67: }
68:
69: public boolean showDlg() {
70: setVisible(true);
71: return isOK;
72: }
73:
74: public void actionPerformed(ActionEvent evt) {
75: if (evt.getSource().equals(btnOK))
76: isOK = true;
77:
78: setVisible(false);
79: }
80: }
|