KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > util > JHostChooser


1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package net.sf.jftp.util;
17
18 import net.sf.jftp.*;
19 import net.sf.jftp.config.*;
20 import net.sf.jftp.gui.framework.*;
21 import net.sf.jftp.net.*;
22 import net.sf.jftp.util.*;
23
24 import java.awt.*;
25 import java.awt.event.*;
26
27 import java.io.*;
28
29 import java.util.*;
30
31 import javax.swing.*;
32 import javax.swing.event.*;
33
34
35 public class JHostChooser extends HFrame implements ActionListener
36 {
37     private JLabel hostL = new JLabel("Host:");
38     private JLabel portL = new JLabel("Port:");
39     private JTextField host = new JTextField(20);
40     private JTextField port = new JTextField(5);
41     private JPanel p1 = new JPanel();
42     private JPanel okP = new JPanel();
43     private JButton ok = new JButton("Use these settings");
44
45     public JHostChooser()
46     {
47         setSize(400, 120);
48         setLocation(200, 250);
49         setTitle("Connection...");
50         getContentPane().setLayout(new BorderLayout());
51         setBackground(Color.lightGray);
52
53         p1.add(hostL);
54         p1.add(host);
55         p1.add(portL);
56         p1.add(port);
57
58         host.setText(RawConnection.host.getText());
59         port.setText(RawConnection.port.getText());
60
61         getContentPane().add("Center", p1);
62         getContentPane().add("South", okP);
63         okP.add(ok);
64         ok.addActionListener(this);
65
66         setVisible(true);
67     }
68
69     public void actionPerformed(ActionEvent e)
70     {
71         if(e.getSource() == ok)
72         {
73             RawConnection.host.setText(host.getText());
74             RawConnection.port.setText(port.getText());
75             RawConnection.established = false;
76             RawConnection.mayDispose = true;
77             this.dispose();
78         }
79     }
80
81     public Insets getInsets()
82     {
83         Insets std = super.getInsets();
84
85         return new Insets(std.top + 5, std.left + 5, std.bottom + 5,
86                           std.right + 5);
87     }
88 }
89
Popular Tags