KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > imr > util > ConnectWindow


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21 package org.jacorb.imr.util;
22
23 import java.awt.*;
24 import javax.swing.*;
25 import java.awt.event.ActionListener JavaDoc;
26 import java.awt.event.ActionEvent JavaDoc;
27
28 /**
29  * ConnectWindow.java
30  *
31  *
32  * Created: Mon Nov 1 18:22:20 1999
33  *
34  */

35
36 public class ConnectWindow extends JFrame implements ActionListener JavaDoc {
37     private JTextField m_imr_url_tf;
38     private JButton m_imr_connect_btn;
39     private JButton m_cancel_btn;
40     private ImRModel m_model;
41     
42     public ConnectWindow(ImRModel model) {
43     super("Connect to remote repository");
44
45     m_model = model;
46
47     JPanel _url_panel = new JPanel();
48     GridBagLayout _url_gbl = new GridBagLayout();
49     GridBagConstraints _constraints = new GridBagConstraints();
50
51     JLabel _url_lbl = new JLabel("Enter a URL:");
52     buildConstraints(_constraints, 0, 0, 1, 1, 1, 1);
53     _constraints.fill = GridBagConstraints.NONE;
54     _url_gbl.setConstraints(_url_lbl, _constraints);
55     _url_panel.add(_url_lbl);
56     
57     m_imr_url_tf = new JTextField("http://", 30);
58     buildConstraints(_constraints, 0, 1, 2, 1, 1, 1);
59     _constraints.fill = GridBagConstraints.HORIZONTAL;
60     _url_gbl.setConstraints(m_imr_url_tf, _constraints);
61     _url_panel.add(m_imr_url_tf);
62
63     m_imr_connect_btn = new JButton("Connect");
64     m_imr_connect_btn.addActionListener(this);
65     buildConstraints(_constraints, 0, 2, 1, 1, 1, 1);
66     _constraints.fill = GridBagConstraints.NONE;
67     _url_gbl.setConstraints(m_imr_connect_btn, _constraints);
68     _url_panel.add(m_imr_connect_btn);
69     
70     m_cancel_btn = new JButton("Cancel");
71     m_cancel_btn.addActionListener(this);
72     buildConstraints(_constraints, 1, 2, 1, 1, 1, 1);
73     _constraints.fill = GridBagConstraints.NONE;
74     _url_gbl.setConstraints(m_cancel_btn, _constraints);
75     _url_panel.add(m_cancel_btn);
76
77     _url_panel.setLayout(_url_gbl);
78
79     getContentPane().add(_url_panel);
80     pack();
81     setVisible(true);
82     }
83
84     private void buildConstraints(GridBagConstraints gbc, int gx, int gy,
85                   int gw, int gh, int wx, int wy){
86     gbc.gridx = gx;
87     gbc.gridy = gy;
88     gbc.gridwidth = gw;
89     gbc.gridheight = gh;
90     gbc.weightx = wx;
91     gbc.weighty = wy;
92     }
93
94     // implementation of java.awt.event.ActionListener interface
95
/**
96      *
97      * @param param1 <description>
98      */

99     public void actionPerformed(ActionEvent JavaDoc event) {
100     JButton _source = (JButton) event.getSource();
101     
102     if (_source == m_cancel_btn)
103         dispose();
104     else if (_source == m_imr_connect_btn){
105         dispose();
106         m_model.connectTo(m_imr_url_tf.getText());
107     }
108     }
109 } // ConnectWindow
110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
Popular Tags