KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > houston > swing > StatusBarPanel


1 /*
2 ** Houston - Status and Logging Toolkit
3 ** Copyright (c) 2001, 2002, 2003 by Gerald Bauer
4 **
5 ** This program is free software.
6 **
7 ** You may redistribute it and/or modify it under the terms of the GNU
8 ** Lesser General Public License as published by the Free Software Foundation.
9 ** Version 2.1 of the license should be included with this distribution in
10 ** the file LICENSE, as well as License.html. If the license is not
11 ** included with this distribution, you may find a copy at the FSF web
12 ** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
13 ** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
14 **
15 ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
16 ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
17 ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
18 ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
19 ** REDISTRIBUTION OF THIS SOFTWARE.
20 **
21 */

22
23 package houston.swing;
24
25 import java.awt.*;
26 import javax.swing.*;
27 import javax.swing.border.*;
28 import houston.*;
29
30 public class StatusBarPanel extends JPanel implements StatusListener
31 {
32    private JLabel _left;
33
34    public StatusBarPanel()
35    {
36       setBorder( BorderFactory.createLoweredBevelBorder() );
37       _left = new JLabel( " " );
38
39       setLayout( new BorderLayout() );
40       add( _left, BorderLayout.CENTER );
41
42       print( "Welcome " + System.getProperty( "user.name" ) );
43
44       Status.addListener( this );
45    }
46
47    public void clear()
48    {
49       _left.setText( " " );
50    }
51
52    public void error( String JavaDoc msg )
53    {
54       printError( msg );
55    }
56
57    public void fatal( String JavaDoc msg )
58    {
59       printError( msg );
60    }
61
62    public void hint( String JavaDoc msg )
63    {
64       print( msg );
65    }
66
67    public void info( String JavaDoc msg )
68    {
69       print( msg );
70    }
71
72    public void info( int level, String JavaDoc msg )
73    {
74       print( msg );
75    }
76
77    public void warning( String JavaDoc msg )
78    {
79       printWarning( msg );
80    }
81
82    private void print( String JavaDoc msg )
83    {
84       _left.setForeground( Color.black );
85       _left.setText( msg );
86    }
87
88    private void printError( String JavaDoc msg )
89    {
90       _left.setForeground( Color.red );
91       _left.setText( msg );
92    }
93
94    private void printWarning( String JavaDoc msg )
95    {
96       _left.setForeground( Color.orange );
97       _left.setText( msg );
98    }
99
100 }
101
Popular Tags