|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel info.rolandkrueger.roklib.ui.swing.StatusBar
public class StatusBar
This class represents a status bar that can be used to display status
messages in a windowed application. The area of a status bar is divided into
two parts. The bar's left half is used as display for general messages. Here,
all types of messages can be displayed by the application. If desired, the
right half of a status bar can be filled with specialized message fields.
Such fields can be used to show the status of a some special part of the
application. In a client-server application, it is conceivable to show the
server address a client is connected to in such a field, for example. These
specialized message fields are added to a status bar with
addElement(String, String)
.
It is possible to display messages in the message area of a status bar that
will be shown for a certain predefined period of time. This is done with
setTimedMessage(String)
. If the delay of a timed message -
which can be defined through the constructor
StatusBar(long)
or with
setMessageDelay(long)
- has elapsed, the timed message is
replaced by the ready message as provided by
setReadyMessage(String)
.
Example: The following code will create a status bar as sketched
below:
StatusBar bar = new StatusBar (); bar.setReadyMessage ("Ready."); bar.addElement ("Msg. field 1", "Help text for message field 1."); bar.addElement ("Other msg. field", "Help text for the other message field."); +-------------------------------+--------------+------------------+ | Ready. | Msg. field 1 | Other msg. field | +-------------------------------+--------------+------------------+
Nested Class Summary | |
---|---|
private class |
StatusBar.BarElement
This class represents a single display area of a status bar. |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
private String |
mCurrentMessage
|
private long |
mDelay
|
private ArrayList<StatusBar.BarElement> |
mElements
|
private JPanel |
mElementsPanel
|
private JLabel |
mInfoLabel
|
private String |
mReadyText
|
private Timer |
mTimer
|
private static long |
serialVersionUID
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
StatusBar()
Default constructor. |
|
StatusBar(long messageDelay)
Constructs a StatusBar with the specified delay for timed messages. |
Method Summary | |
---|---|
int |
addElement(String text,
String helpText)
Adds a specialized message field to the right half of the status bar. |
void |
hoverEnded(Hoverable source)
|
void |
hoverStarted(Hoverable source)
|
void |
setElementHelpText(int elementNr,
String helpText)
Sets the help text that belongs to the spezialized message area with the given identification number. |
void |
setElementText(int elementNr,
String text)
Sets the text displayed by the spezialized message area with the given identification number. |
void |
setMessageDelay(long delay)
Sets the amount of time in milliseconds of how long a timed message will be displayed. |
void |
setReadyMessage(String msg)
Sets the ready message for this status bar. |
void |
setTimedMessage(String msg)
A timed message will be displayed in the message area for a certain amount of time. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private JLabel mInfoLabel
private JPanel mElementsPanel
private Timer mTimer
private long mDelay
private String mReadyText
private String mCurrentMessage
private ArrayList<StatusBar.BarElement> mElements
Constructor Detail |
---|
public StatusBar()
setTimedMessage(String)
public StatusBar(long messageDelay)
StatusBar
with the specified delay for timed messages.
messageDelay
- delay in milliseconds for timed messagessetTimedMessage(String)
Method Detail |
---|
public void hoverStarted(Hoverable source)
hoverStarted
in interface HoverListener
public void hoverEnded(Hoverable source)
hoverEnded
in interface HoverListener
public void setReadyMessage(String msg)
msg
- the ready message for this status bar.public void setTimedMessage(String msg)
StatusBar(long)
or through method
setMessageDelay(long)
. After the delay has elapsed, the
status bar's ready message is displayed again.
msg
- the message to be displayed for some timepublic void setMessageDelay(long delay)
delay
- the amount of time in milliseconds of how long a timed message
will be displayedsetTimedMessage(String)
public int addElement(String text, String helpText)
text
will be displayed in that field. The given
helpText
will be displayed in the general message area while
the mouse cursor hovers over the specialized message field. Both of these
text messages can be changed with
setElementText(int, String)
and
setElementHelpText(int, String)
, respectively. The
int
value that is returned by this method is the
identification number of the new specialized message field. This number is
needed for the first parameter of the setElement*
methods and
indicates the field that is meant to be changed.
text
- the text that will be displayed in the text areahelpText
- help text for the text area that will be displayed in the general
text area when the mouse hovers over the new text area
setElementHelpText(int, String)
,
setElementText(int, String)
public void setElementText(int elementNr, String text)
elementNr
- identification number as provided by
addElement(String, String)
which refers to the
message field that is to be changed by this methodtext
- the text to be displayed by the message field
ArrayIndexOutOfBoundsException
- if the message field denoted by elementNr
does not
existpublic void setElementHelpText(int elementNr, String helpText)
elementNr
- identification number as provided by
addElement(String, String)
which refers to the
message field that is to be changed by this methodhelpText
- the text to be displayed by the message field
ArrayIndexOutOfBoundsException
- if the message field denoted by elementNr
does not
exist
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |