Source code: com/eireneh/bible/view/swing/beans/StatusBar.java
1
2 package com.eireneh.bible.view.swing.beans;
3
4 import java.awt.*;
5 import java.awt.event.*;
6 import javax.swing.*;
7 import javax.swing.text.*;
8
9 /**
10 * The status bar provides usefull info to the user as to the current
11 * state of the program.
12 * <p>We need to think about the stuff to put in here:<ul>
13 * <li>A status message. This changes with what the user is pointing at,
14 * so is very similar to tool-tips. Although they are commonly more
15 * instructional.
16 * <li>A set of panels that tell you the time/if CAPS is presses and so on
17 * </ul>
18 * <p>TODO: Make this do something more useful
19 *
20 * <table border='1' cellPadding='3' cellSpacing='0' width="100%">
21 * <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
22 * Distribution Licence:<br />
23 * Project B is free software; you can redistribute it
24 * and/or modify it under the terms of the GNU General Public License,
25 * version 2 as published by the Free Software Foundation.<br />
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * General Public License for more details.<br />
30 * The License is available on the internet
31 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
32 * <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
33 * MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
34 * The copyright to this program is held by it's authors.
35 * </font></td></tr></table>
36 * @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
37 * @see docs.Licence
38 * @author Joe Walker
39 * @version D2.I0.T0
40 */
41 public class StatusBar extends JComponent implements MouseListener
42 {
43 /**
44 * Create a new StatusBar
45 */
46 public StatusBar()
47 {
48 jbInit();
49 }
50
51 /**
52 * Init the GUI
53 */
54 private void jbInit()
55 {
56 lbl_message.setBorder(BorderFactory.createEtchedBorder());
57 lbl_message.setText(DEFAULT);
58
59 lbl_name.setBorder(BorderFactory.createEtchedBorder());
60 lbl_name.setText(" ProjectB v0.8 ");
61
62 this.setLayout(new GridBagLayout());
63 this.setBorder(BorderFactory.createLoweredBevelBorder());
64 this.add(lbl_message, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0
65 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
66 this.add(lbl_name, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
67 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
68 }
69
70 /**
71 * When the mouse points at something that has registered with us
72 * to be shown on the statusbar
73 */
74 public void mouseEntered(MouseEvent ev)
75 {
76 if (ev.getSource() instanceof AbstractButton)
77 {
78 AbstractButton button = (AbstractButton) ev.getSource();
79 Action action = button.getAction();
80
81 if (action != null)
82 {
83 Object value = action.getValue(Action.LONG_DESCRIPTION);
84
85 if (value != null)
86 lbl_message.setText(value.toString());
87 }
88 }
89 }
90
91 /**
92 * When the mouse no longer points at something that has registered with us
93 */
94 public void mouseExited(MouseEvent ev)
95 {
96 lbl_message.setText(DEFAULT);
97 }
98
99 /**
100 * Invoked when the mouse has been clicked on a component.
101 * Ignored
102 */
103 public void mouseClicked(MouseEvent ev)
104 {
105 }
106
107 /**
108 * Invoked when a mouse button has been pressed on a component.
109 * Ignored
110 */
111 public void mousePressed(MouseEvent ev)
112 {
113 }
114
115 /**
116 * Invoked when a mouse button has been released on a component.
117 * Ignored
118 */
119 public void mouseReleased(MouseEvent ev)
120 {
121 }
122
123 /** The default text */
124 private static final String DEFAULT = "Ready ... ";
125
126 private JLabel lbl_message = new JLabel();
127 private JLabel lbl_name = new JLabel();
128 }