]> code.citadel.org Git - citadel.git/blob - shaggy/hostPanel.java
* fix_scrollbar_bug is now a class instead of an id. Fixes validator warnings.
[citadel.git] / shaggy / hostPanel.java
1 import javax.swing.*;
2 import java.awt.*;
3 import java.awt.event.*;
4
5 public class hostPanel extends JPanel {
6   JTextField    h_name, dns_name, port, user, pass;
7
8   public hostPanel() {
9     super( new BorderLayout() );
10
11     String[]    data = { 
12       "127.0.0.1",
13       "uncnsrd.mt-kisco.ny.us"
14     };
15
16     JPanel      p = new JPanel();
17     p.setBorder( BorderFactory.createTitledBorder( 
18                   BorderFactory.createEtchedBorder(), "Nodes" ) );
19
20     final JList theList;
21
22     p.setLayout( new BorderLayout() );
23     p.add( "Center", new JScrollPane( theList = new JList( data ) ) );
24     add( "West", p );
25
26     MouseListener mouseListener = new MouseAdapter() {
27       public void mouseClicked(MouseEvent e) {
28         String  where = (String)theList.getSelectedValue();
29         if( where == null ) return;
30         dns_name.setText( where );
31         if (e.getClickCount() == 2) {
32           citadel.me.setServer( where, port.getText() );
33           citadel.me.showLoginPanel( user.getText(), pass.getText() );
34         }
35       }
36     };
37     theList.addMouseListener(mouseListener);
38
39
40     //    theList.setPrototypeCellValue("1 and 1 and 1 is 3");
41
42     PairPanel   pp = new PairPanel(3, 10);
43     pp.addLeft( new JLabel( "BBS Name:" ) );
44     pp.addRight( h_name = new JTextField( 20 ) );
45     h_name.addActionListener( new ActionListener() {
46       public void actionPerformed( ActionEvent e ) {
47         dns_name.requestFocus();
48       } } );
49
50     pp.addLeft( new JLabel( "IP Address:" ) );
51     pp.addRight( dns_name = new JTextField( 20 ) );
52     dns_name.setText( "127.0.0.1" );
53     dns_name.addActionListener( new ActionListener () {
54       public void actionPerformed( ActionEvent e ) {
55         port.requestFocus();
56       } } );
57    
58     pp.addLeft( new JLabel( "Port:" ) );
59     pp.addRight( port = new JTextField( "504" ) );
60     port.addActionListener( new ActionListener() {
61       public void actionPerformed( ActionEvent e ) {
62         user.requestFocus();
63       } } );
64
65     pp.addLeft( new JLabel( "Username:" ) );
66     pp.addRight( user = new JTextField( 10 ) );
67     user.addActionListener( new ActionListener() {
68       public void actionPerformed( ActionEvent e ) {
69         pass.requestFocus();
70       } } );
71
72     pp.addLeft( new JLabel( "Password:" ) );
73     pp.addRight( pass = new JPasswordField( 10 ) );
74     pass.addActionListener(new ActionListener() {
75       public void actionPerformed( ActionEvent e ) {
76         citadel.me.setServer( dns_name.getText(), port.getText() );
77         citadel.me.showLoginPanel( user.getText(), pass.getText() );
78       }
79     });
80
81     add( "Center", pp );
82
83     JButton     but = new JButton( "Connect" );
84     but.addActionListener(new ActionListener() {
85       public void actionPerformed( ActionEvent e ) {
86         citadel.me.setServer( dns_name.getText(), port.getText() );
87         citadel.me.showLoginPanel( user.getText(), pass.getText() );
88       }
89     });
90
91     JPanel      pane = new JPanel();
92     pane.setBorder(BorderFactory.createEmptyBorder(30, //top
93                                                    30, //left   
94                                                    10, //bottom
95                                                    30) );//right
96
97     pane.add( but );
98     add( "South", pane );
99   }
100
101   public void refresh() {
102   }
103 }
104
105