home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
StatusBar.java
< prev
next >
Wrap
Text File
|
1998-08-21
|
6KB
|
190 lines
package symantec.itools.awt;
import java.awt.Color;
import java.awt.BorderLayout;
import java.awt.Label;
import java.awt.LayoutManager;
import java.beans.PropertyVetoException;
import java.beans.PropertyChangeListener;
import java.beans.VetoableChangeListener;
import java.beans.PropertyChangeEvent;
// 06/03/97 TGL Converted to 1.1, added bound/constrained
// 07/18/97 LAB Made bound and constrained listener registration functions call their super.
// Cleaned up the code a little. Addeed version and author tags. Changed
// incorrect calls to invalidate() to repaint().
/**
* Use a StatusBar to show document status and other information, like the
* meaning of a button or other user interface element in a window. Typically,
* a status bar appears at the bottom of a window.
*
* @version 1.1, July 18, 1997
* @author Symantec
*/
public class StatusBar extends BorderPanel
{
/**
* Constructs a default StatusBar.
* It is constructed with the BEVEL_LINE style.
*/
public StatusBar()
{
super.setLayout(new BorderLayout());
add("Center", text = new Label());
}
/**
* Sets the text that is displayed.
* @param s the new text to display
* @see #getStatusText
* @exception PropertyVetoException
* if the specified property value is unacceptable
*/
public void setStatusText(String s) throws PropertyVetoException
{
if (! symantec.itools.util.GeneralUtils.objectsEqual(text.getText(), s))
{
String oldText = text.getText();
vetos.fireVetoableChange("StatusText", oldText, s);
text.setText(s);
repaint();
changes.firePropertyChange("StatusText", oldText, s);
}
}
/**
* Gets the text currently displayed.
* @return the text currently displayed
* @see #setStatusText
*/
public String getStatusText()
{
return text.getText();
}
/**
* Sets the color of the text that is displayed.
* @param s the new text color
* @see #getStatusTextColor
* @exception PropertyVetoException
* if the specified property value is unacceptable
*/
public void setStatusTextColor(Color c) throws PropertyVetoException
{
if (! symantec.itools.util.GeneralUtils.objectsEqual(textColor, c))
{
Color oldColor = textColor;
vetos.fireVetoableChange("StatusTextColor", oldColor, c);
textColor = c;
text.setForeground(c);
repaint();
changes.firePropertyChange("StatusTextColor", oldColor, c);
}
}
/**
* Gets the text color currently displayed.
* @return the current color of displayed text
* @see #setStatusTextColor
*/
public Color getStatusTextColor()
{
return textColor;
}
/**
* Takes no action.
* This is a standard Java AWT method which gets called to specify
* which layout manager should be used to layout the components in
* standard containers.
*
* Since layout managers CANNOT BE USED with this container the standard
* setLayout has been OVERRIDDEN for this container and does nothing.
*
* @param l the layout manager to use to layout this container's components
* (IGNORED)
* @see java.awt.Container#getLayout
**/
public void setLayout(LayoutManager l)
{
}
/**
* Clears the text that gets displayed.
* @see #setStatusText
*/
public void clear()
{
try
{
setStatusText("");
}
catch (PropertyVetoException veto) {}
}
/**
* Adds a listener for all event changes.
* @param listener the listener to add.
* @see #removePropertyChangeListener
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
{
super.addPropertyChangeListener(listener);
changes.addPropertyChangeListener(listener);
}
/**
* Removes a listener for all event changes.
* @param listener the listener to remove.
* @see #addPropertyChangeListener
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
{
super.removePropertyChangeListener(listener);
changes.removePropertyChangeListener(listener);
}
/**
* Adds a vetoable listener for all event changes.
* @param listener the listener to add.
* @see #removeVetoableChangeListener
*/
public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
{
super.addVetoableChangeListener(listener);
vetos.addVetoableChangeListener(listener);
}
/**
* Removes a vetoable listener for all event changes.
* @param listener the listener to remove.
* @see #addVetoableChangeListener
*/
public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
{
super.removeVetoableChangeListener(listener);
vetos.removeVetoableChangeListener(listener);
}
/**
* The text to display.
*/
protected Label text;
/**
* The color of the displayed text.
*/
protected Color textColor;
// Private members
private symantec.itools.beans.VetoableChangeSupport vetos = new symantec.itools.beans.VetoableChangeSupport(this);
private symantec.itools.beans.PropertyChangeSupport changes = new symantec.itools.beans.PropertyChangeSupport(this);
}