001: // Class defining a status bar
002: package com.pk;
003:
004: import javax.swing.*;
005: import javax.swing.border.*;
006: import java.awt.*;
007:
008: class StatusBar extends JPanel implements Constants {
009: /**
010: *
011: */
012: private static final long serialVersionUID = -4915779892342583217L;
013:
014: // Constructor
015: public StatusBar() {
016: setLayout(new FlowLayout(FlowLayout.LEFT, 10, 3));
017: setBackground(Color.lightGray);
018: setBorder(BorderFactory.createLineBorder(Color.darkGray));
019: setUserPane(DEFAULT_ELEMENT_USER);
020: setElapsedTimePane("");
021: setMessagePane("");
022: add(userPane); // Add color pane to status bar
023: add(elapsedTimePane);
024: add(messagePane); // Add type pane to status bar
025: }
026:
027: // Set type pane label
028: public void setElapsedTimePane(String text) {
029: elapsedTimePane.setText(text);
030: }
031:
032: public void setMessagePane(String text) {
033: messagePane.setText(text); // Set the pane text
034: }
035:
036: public void setUserPane(String text) {
037: userPane.setText(text); // Set the pane text
038: }
039:
040: // Panes in the status bar
041: public StatusPane messagePane = new StatusPane("");
042: public StatusPaneTime elapsedTimePane = new StatusPaneTime("");
043: private StatusPaneSmall userPane = new StatusPaneSmall("");
044:
045: // Class defining a status bar pane
046: class StatusPane extends JLabel {
047: /**
048: *
049: */
050: private static final long serialVersionUID = 3513784308329811461L;
051:
052: public StatusPane(String text) {
053: setBackground(Color.lightGray); // Set background color
054: setForeground(Color.black);
055: //setFont(paneFont); // Set the fixed font
056: setHorizontalAlignment(CENTER); // Center the pane text
057: setBorder(BorderFactory
058: .createBevelBorder(BevelBorder.LOWERED));
059: //setPreferredSize(new Dimension(400,20));
060: setHorizontalAlignment(LEFT);
061: setText(text); // Set the text in the pane
062: }
063: // Font for pane text
064: //private Font paneFont = new Font("Serif", Font.PLAIN, 12);
065: }
066:
067: class StatusPaneTime extends JLabel {
068: /**
069: *
070: */
071: private static final long serialVersionUID = -6145213924965322048L;
072:
073: public StatusPaneTime(String text) {
074: setBackground(Color.lightGray); // Set background color
075: setForeground(Color.black);
076: //setFont(paneFont); // Set the fixed font
077: setHorizontalAlignment(CENTER); // Center the pane text
078: setBorder(BorderFactory
079: .createBevelBorder(BevelBorder.LOWERED));
080: //setPreferredSize(new Dimension(400,20));
081: setHorizontalAlignment(LEFT);
082: setText(text); // Set the text in the pane
083: }
084: // Font for pane text
085: //private Font paneFont = new Font("Serif", Font.PLAIN, 12);
086: }
087:
088: class StatusPaneSmall extends JLabel {
089: /**
090: *
091: */
092: private static final long serialVersionUID = -2250303985616849791L;
093:
094: public StatusPaneSmall(String text) {
095: setBackground(Color.lightGray); // Set background color
096: setForeground(Color.black);
097: //setFont(paneFont); // Set the fixed font
098: setHorizontalAlignment(CENTER); // Center the pane text
099: setBorder(BorderFactory
100: .createBevelBorder(BevelBorder.LOWERED));
101: //setPreferredSize(new Dimension(100,20));
102: setHorizontalAlignment(LEFT);
103: setText(text); // Set the text in the pane
104: }
105:
106: // Font for pane text
107: //private Font paneFont = new Font("Serif", Font.PLAIN, 12);
108: //private Font paneFont = new Font("Default", Font.PLAIN, 12);
109: }
110: }
|