]> code.citadel.org Git - citadel.git/blob - shaggy/roomInfoWindow.java
CSS : pretty buttons to attendee's reply messages
[citadel.git] / shaggy / roomInfoWindow.java
1 import javax.swing.*;
2 import java.awt.*;
3 import java.awt.event.*;
4
5 public class roomInfoWindow extends JFrame {
6     roomInfo    ri;
7     JTextArea   info;
8
9
10     public roomInfoWindow( roomInfo ri ) {
11         Container       c;
12
13         setTitle( "Info for " + ri.name );
14         this.ri = ri;
15
16         JPanel  p = new JPanel();
17         p.setLayout( new BorderLayout() );
18         p.setBorder( BorderFactory.createTitledBorder( 
19                                                       BorderFactory.createEtchedBorder(), ri.name ) );
20
21         p.add( "Center", 
22                new JScrollPane( info = new JTextArea(),
23                                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
24                                 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ) );
25
26         info.setEditable( false );
27         info.setLineWrap( true );
28         info.setWrapStyleWord( true );
29
30         VertPanel       vp = new VertPanel();
31         vp.add( new JLabel( ri.total + " messages" ) );
32         vp.add( new JLabel( "Floor: " + citadel.me.rooms.getFloor( ri.floor ).name() ) );
33         JCheckBox       cb;
34         vp.add( cb = new JCheckBox( "Permanent", ri.perm ) );
35         cb.setEnabled( false );
36         vp.add( cb = new JCheckBox( "Private", ri.priv ) );
37         cb.setEnabled( false );
38         vp.add( cb = new JCheckBox( "Password", ri.pass ) );
39         cb.setEnabled( false );
40         vp.add( cb = new JCheckBox( "Directory", ri.dir ) );
41         cb.setEnabled( false );
42         vp.add( cb = new JCheckBox( "Networked", ri.net ) );
43         cb.setEnabled( false );
44         p.add( "East", vp );
45
46         c = getContentPane();
47         c.setLayout( new BorderLayout() );
48         c.add( "Center", p );
49         
50         JPanel  pp = new JPanel();
51         final JButton   change = new JButton( "Change Info" );
52         pp.add( change );
53         change.setEnabled( false );
54         change.addActionListener( new ActionListener() {
55           public void actionPerformed( ActionEvent e ) {
56             citadel.me.networkEvent( "EINF 1", info.getText(), new CallBack() {
57               public void run( citReply r ) {
58                 refresh();
59               } } );
60           } } );
61
62         JButton b;
63
64         pp.add( b = new JButton( "Close" ) );
65         b.addActionListener( new ActionListener() {
66             public void actionPerformed( ActionEvent e ) {
67                 closeWin();
68             } } );
69
70         c.add( "South", pp );
71
72         addWindowListener( new WindowAdapter() {
73             public void windowClosing( WindowEvent e ) {
74                 closeWin();
75             } } );
76
77         setSize( 400, 400 );
78         show();
79
80         citadel.me.registerWindow( this );
81         refresh();
82         citadel.me.networkEvent( "EINF 0", new CallBack() {
83           public void run( citReply r ) {
84             if( r.ok() ) {
85               info.setEditable( true );
86               change.setEnabled( true );
87             }
88           } } );
89
90     }
91
92     public void refresh() {
93         citadel.me.networkEvent( "RINF", new CallBack() {
94             public void run( citReply r ) {
95                 if( r.error() ) info.setText( r.getArg(0) );
96                 else info.setText( r.getData() );
97             } } );
98     }   
99
100     public void closeWin() {
101         citadel.me.removeWindow( this );
102         dispose();
103     }
104
105 }
106
107
108
109
110
111
112