01: /*
02: ** Houston - Status and Logging Toolkit
03: ** Copyright (c) 2001, 2002, 2003 by Gerald Bauer
04: **
05: ** This program is free software.
06: **
07: ** You may redistribute it and/or modify it under the terms of the GNU
08: ** Lesser General Public License as published by the Free Software Foundation.
09: ** 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: private JLabel _left;
32:
33: public StatusBarPanel() {
34: setBorder(BorderFactory.createLoweredBevelBorder());
35: _left = new JLabel(" ");
36:
37: setLayout(new BorderLayout());
38: add(_left, BorderLayout.CENTER);
39:
40: print("Welcome " + System.getProperty("user.name"));
41:
42: Status.addListener(this );
43: }
44:
45: public void clear() {
46: _left.setText(" ");
47: }
48:
49: public void error(String msg) {
50: printError(msg);
51: }
52:
53: public void fatal(String msg) {
54: printError(msg);
55: }
56:
57: public void hint(String msg) {
58: print(msg);
59: }
60:
61: public void info(String msg) {
62: print(msg);
63: }
64:
65: public void info(int level, String msg) {
66: print(msg);
67: }
68:
69: public void warning(String msg) {
70: printWarning(msg);
71: }
72:
73: private void print(String msg) {
74: _left.setForeground(Color.black);
75: _left.setText(msg);
76: }
77:
78: private void printError(String msg) {
79: _left.setForeground(Color.red);
80: _left.setText(msg);
81: }
82:
83: private void printWarning(String msg) {
84: _left.setForeground(Color.orange);
85: _left.setText(msg);
86: }
87:
88: }
|