]> code.citadel.org Git - citadel.git/blob - shaggy/pageUserWindow.java
* fix_scrollbar_bug is now a class instead of an id. Fixes validator warnings.
[citadel.git] / shaggy / pageUserWindow.java
1 import javax.swing.*;
2 import java.awt.*;
3 import java.awt.event.*;
4
5 public class pageUserWindow extends JFrame {
6     String      who;
7     Container   c;
8     boolean     done;
9
10     public pageUserWindow() {
11         c = getContentPane();
12         c.setLayout( new BorderLayout() );
13
14         JPanel  p = new JPanel();
15         final JComboBox jcb = new JComboBox();
16
17         p.add( jcb );
18         c.add( "North", jcb );
19         jcb.addActionListener( new ActionListener() {
20             public void actionPerformed( ActionEvent e ) {
21                 who = (String)jcb.getSelectedItem();
22             } } );
23
24         citadel.me.networkEvent( "RWHO", new CallBack() {
25             public void run( citReply r ) {
26                 if( !r.error() ) {
27                     if( jcb.getModel().getSize() > 0 ) 
28                         jcb.removeAllItems();
29                  
30                     String      s;
31                     int         i = 0;
32                     while( (s = r.getLine( i++ )) != null ) {
33                         int     j,k;
34                         j = s.indexOf( "|" ) + 1;
35                         k = s.indexOf( "|", j );
36                         jcb.addItem( s.substring( j, k ) );
37                     }
38                 }
39             } } );
40         
41         setUp();
42     }
43
44     public pageUserWindow( String who ) {
45         this.who = who;
46         c = getContentPane();
47         c.setLayout( new BorderLayout() );
48         c.add( "North", new JLabel( "Message to : " + who ) );
49
50         setUp();
51     }
52
53     public void setUp() {
54         JPanel  p = new JPanel();
55         p.setLayout( new BorderLayout() );
56         p.setBorder( BorderFactory.createTitledBorder( 
57                      BorderFactory.createEtchedBorder(), "Message" ) );
58
59         final JTextArea t = new JTextArea();
60         t.setLineWrap( true );
61         t.setWrapStyleWord( true );
62         p.add( "Center", t );
63
64         c.add( "Center", p );
65
66         p = new JPanel();
67         JButton b;
68         p.add( b = new JButton( "Send" ) );
69         b.addActionListener( new ActionListener() {
70             public void actionPerformed( ActionEvent e ) {
71                 citadel.me.networkEvent( "SEXP " + who + "|-", t.getText() );
72                 closeWin();
73             } } );
74
75         p.add( b = new JButton( "Cancel" ) );
76         b.addActionListener( new ActionListener() {
77             public void actionPerformed( ActionEvent e ) {
78                 closeWin();
79             } } );
80         c.add( "South", p );
81
82         addWindowListener( new WindowAdapter() {
83             public void windowClosing( WindowEvent e ) {
84                 closeWin();
85             }
86         } );
87
88         citadel.me.registerWindow( this );
89         pack();
90         show();
91     }
92
93     public void closeWin() {
94         citadel.me.removeWindow( this );
95         dispose();
96     }
97 }