Java Platform 1.2
Beta 4

Class com.sun.java.swing.JProgressBar

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--com.sun.java.swing.JComponent
                    |
                    +--com.sun.java.swing.JProgressBar

public class JProgressBar
extends JComponent
implements SwingConstants, Accessible
A component that displays an integer value within a bounded interval. A progress bar typically communicates the progress of an event by displaying its percentage of completion and possibly a textual display of this percentage.

Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.

See Also:
Serialized Form

Inner Class Summary
protected   JProgressBar.AccessibleJProgressBar
          The class used to obtain the accessible role for this object.
 
Inner classes inherited from class com.sun.java.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  ChangeEvent changeEvent
          Only one ChangeEvent is needed per instance since the event's only interesting property is the immutable source, which is the progress bar.
protected  ChangeListener changeListener
           
protected  BoundedRangeModel model
           
protected  int orientation
           
protected  boolean paintBorder
           
protected  boolean paintString
           
protected  String progressString
           
 
Fields inherited from class com.sun.java.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
 
Constructor Summary
JProgressBar()
          Creates a horizontal progress bar.
JProgressBar(BoundedRangeModel newModel)
          Creates a horizontal progress bar.
JProgressBar(int orient, int min, int max)
          Creates a progress bar using the specified orientation, minimum, and maximum.
JProgressBar(int min, int max)
          Creates a horizontal progress bar using the specified minimum and maximum.
JProgressBar(int orient)
          Creates a progress bar with the specified orientation, which can be either HORIZONTAL or VERTICAL. Uses the defaultMinimum and defaultMaximum.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener to the button.
protected  ChangeListener createChangeListener()
           
protected  void fireStateChanged()
          Notify all listeners that have registered interest for notification on this event type.
 AccessibleContext getAccessibleContext()
          Get the AccessibleContext associated with this JComponent
 int getMaximum()
          Returns the model's maximum value.
 int getMinimum()
          Returns the model's minimum value.
 BoundedRangeModel getModel()
          Returns the data model used by the JProgressBar.
 int getOrientation()
          Returns JProgressBar.
 double getPercentComplete()
          Returns the percentage/percent complete for the progress bar.
 String getString()
          Returns the current value of the Progress String.
 ProgressBarUI getUI()
          Returns the L&F object that renders this component.
 String getUIClassID()
          Returns the name of the L&F class that renders this component.
 int getValue()
          Returns the model's current value.
 boolean isBorderPainted()
          Returns true if the progress bar has a border or false if it does not.
 boolean isStringPainted()
          Returns true if the progress bar will render a string onto the representation of the progress bar.
protected  void paintBorder(Graphics g)
          Paint the progress bar's border if BorderPainted property is true.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from the button.
 void setBorderPainted(boolean b)
          Sets whether the progress bar should have a border.
 void setMaximum(int n)
          Sets the model's maximum to x.
 void setMinimum(int n)
          Sets the model's minimum to x.
 void setModel(BoundedRangeModel newModel)
          Sets the data model used by the JProgressBar.
 void setOrientation(int newOrientation)
          Sets the progress bar's orientation to newOrientation, which must be JProgressBar.
 void setString(String s)
          Sets the value of the Progress String.
 void setStringPainted(boolean b)
          Sets whether the progress bar will render a percent string.
 void setUI(ProgressBarUI ui)
          Sets the L&F object that renders this component.
 void setValue(int n)
          Sets the model's current value to x.
 void updateUI()
          Notification from the UIFactory that the L&F has changed.
 
Methods inherited from class com.sun.java.swing.JComponent
addAncestorListener , addNotify , addPropertyChangeListener , addVetoableChangeListener , computeVisibleRect , contains , createToolTip , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , fireVetoableChange , getActionForKeyStroke , getAlignmentX , getAlignmentY , getAutoscrolls , getBorder , getBounds , getClientProperty , getComponentGraphics , getConditionForKeyStroke , getDebugGraphicsOptions , getGraphics , getHeight , getInsets , getInsets , getLocation , getMaximumSize , getMinimumSize , getNextFocusableComponent , getPreferredSize , getRegisteredKeyStrokes , getRootPane , getSize , getToolTipLocation , getToolTipText , getToolTipText , getTopLevelAncestor , getVisibleRect , getWidth , getX , getY , grabFocus , hasFocus , isDoubleBuffered , isFocusCycleRoot , isFocusTraversable , isLightweightComponent , isManagingFocus , isOpaque , isOptimizedDrawingEnabled , isPaintingTile , isRequestFocusEnabled , isValidateRoot , paint , paintChildren , paintComponent , paintImmediately , paintImmediately , processComponentKeyEvent , processFocusEvent , processKeyEvent , processMouseMotionEvent , putClientProperty , registerKeyboardAction , registerKeyboardAction , removeAncestorListener , removeNotify , removePropertyChangeListener , removeVetoableChangeListener , repaint , repaint , requestDefaultFocus , requestFocus , resetKeyboardActions , reshape , revalidate , scrollRectToVisible , setAlignmentX , setAlignmentY , setAutoscrolls , setBorder , setDebugGraphicsOptions , setDoubleBuffered , setEnabled , setMaximumSize , setMinimumSize , setNextFocusableComponent , setOpaque , setPreferredSize , setRequestFocusEnabled , setToolTipText , setUI , setVisible , unregisterKeyboardAction , update
 
Methods inherited from class java.awt.Container
add , add , add , add , add , addContainerListener , addImpl , countComponents , deliverEvent , doLayout , findComponentAt , findComponentAt , getComponent , getComponentAt , getComponentAt , getComponentCount , getComponents , getLayout , insets , invalidate , isAncestorOf , layout , list , list , locate , minimumSize , paintComponents , paramString , preferredSize , print , printComponents , processContainerEvent , processEvent , remove , remove , removeAll , removeContainerListener , setLayout , validate , validateTree
 
Methods inherited from class java.awt.Component
action , add , addComponentListener , addFocusListener , addInputMethodListener , addKeyListener , addMouseListener , addMouseMotionListener , addPropertyChangeListener , bounds , checkImage , checkImage , coalesceEvents , contains , createImage , createImage , disable , disableEvents , dispatchEvent , enable , enable , enableEvents , enableInputMethods , getBackground , getBounds , getColorModel , getComponentOrientation , getCursor , getDropTarget , getFont , getFontMetrics , getForeground , getInputContext , getInputMethodRequests , getLocale , getLocation , getLocationOnScreen , getName , getParent , getPeer , getSize , getToolkit , getTreeLock , gotFocus , handleEvent , hide , imageUpdate , inside , isDisplayable , isEnabled , isLightweight , isShowing , isValid , isVisible , keyDown , keyUp , list , list , list , location , lostFocus , mouseDown , mouseDrag , mouseEnter , mouseExit , mouseMove , mouseUp , move , nextFocus , paintAll , postEvent , prepareImage , prepareImage , printAll , processComponentEvent , processInputMethodEvent , processMouseEvent , remove , removeComponentListener , removeFocusListener , removeInputMethodListener , removeKeyListener , removeMouseListener , removeMouseMotionListener , removePropertyChangeListener , repaint , repaint , repaint , resize , resize , setBackground , setBounds , setBounds , setComponentOrientation , setCursor , setDropTarget , setFont , setForeground , setLocale , setLocation , setLocation , setName , setSize , setSize , show , show , size , toString , transferFocus
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait
 

Field Detail

orientation

protected int orientation

paintBorder

protected boolean paintBorder

model

protected BoundedRangeModel model

progressString

protected String progressString

paintString

protected boolean paintString

changeEvent

protected transient ChangeEvent changeEvent
Only one ChangeEvent is needed per instance since the event's only interesting property is the immutable source, which is the progress bar.

changeListener

protected ChangeListener changeListener
Constructor Detail

JProgressBar

public JProgressBar()
Creates a horizontal progress bar. Uses the defaultMinimum and defaultMaximum.

JProgressBar

public JProgressBar(int orient)
Creates a progress bar with the specified orientation, which can be either HORIZONTAL or VERTICAL. Uses the defaultMinimum and defaultMaximum.

JProgressBar

public JProgressBar(int min,
                    int max)
Creates a horizontal progress bar using the specified minimum and maximum.

JProgressBar

public JProgressBar(int orient,
                    int min,
                    int max)
Creates a progress bar using the specified orientation, minimum, and maximum.

JProgressBar

public JProgressBar(BoundedRangeModel newModel)
Creates a horizontal progress bar. Uses the specified BoundedRangeModel.
Method Detail

getOrientation

public int getOrientation()
Returns JProgressBar.VERTICAL or JProgressBar.HORIZONTAL, depending on the orientation of the progress bar. The default orientation is HORIZONTAL.
Returns:
HORIZONTAL or VERTICAL

setOrientation

public void setOrientation(int newOrientation)
Sets the progress bar's orientation to newOrientation, which must be JProgressBar.VERTICAL or JProgressBar.HORIZONTAL. The default orientation is HORIZONTAL.
Parameters:
newOrientation - HORIZONTAL or VERTICAL
Throws:
IllegalArgumentException - if newOrientation is an illegal value

isStringPainted

public boolean isStringPainted()
Returns true if the progress bar will render a string onto the representation of the progress bar. Returns false if it will not do this rendering.
Returns:
whether the progress bar renders a percent string
See Also:
setStringPainted

setStringPainted

public void setStringPainted(boolean b)
Sets whether the progress bar will render a percent string.
Parameters:
b - true if the progress bar will render a percent string.
See Also:
isStringPainted

getString

public String getString()
Returns the current value of the Progress String. If you are providing a custom Progress String via this method, you will want to ensure that you call setString() before you call getString();
Returns:
the value of the percent string
See Also:
setString

setString

public void setString(String s)
Sets the value of the Progress String. If you are providing a custom Progress String via this method, you will want to ensure that you call setString() before you call getString();
Parameters:
s - the value of the percent string
See Also:
getString

getPercentComplete

public double getPercentComplete()
Returns the percentage/percent complete for the progress bar. Note that, as a double, this number is between 0.00 and 1.00.
Returns:
the percent complete for this progress bar.

isBorderPainted

public boolean isBorderPainted()
Returns true if the progress bar has a border or false if it does not.
Returns:
whether the progress bar has a border
See Also:
setBorderPainted

setBorderPainted

public void setBorderPainted(boolean b)
Sets whether the progress bar should have a border.
Parameters:
b - true if the progress bar should have a border
See Also:
isBorderPainted

paintBorder

protected void paintBorder(Graphics g)
Paint the progress bar's border if BorderPainted property is true.
Parameters:
g - the Graphics context within which to paint the border
Overrides:
paintBorder in class JComponent
See Also:
JComponent.paint(java.awt.Graphics), JComponent.setBorder(com.sun.java.swing.border.Border)

getUI

public ProgressBarUI getUI()
Returns the L&F object that renders this component.
Returns:
the ProgressBarUI object that renders this component

setUI

public void setUI(ProgressBarUI ui)
Sets the L&F object that renders this component.
Parameters:
ui - the ProgressBarUI L&F object
See Also:
UIDefaults.getUI(com.sun.java.swing.JComponent)

updateUI

public void updateUI()
Notification from the UIFactory that the L&F has changed. Called to replace the UI with the latest version from the UIFactory.
Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
Returns the name of the L&F class that renders this component.
Returns:
"ProgressBarUI"
Overrides:
getUIClassID in class JComponent
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(com.sun.java.swing.JComponent)

createChangeListener

protected ChangeListener createChangeListener()

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the button.
Parameters:
l - the ChangeListener to add

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the button.
Parameters:
l - the ChangeListener to remove

fireStateChanged

protected void fireStateChanged()
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
See Also:
EventListenerList

getModel

public BoundedRangeModel getModel()
Returns the data model used by the JProgressBar.
Returns:
the BoundedRangeModel currently in use
See Also:
BoundedRangeModel

setModel

public void setModel(BoundedRangeModel newModel)
Sets the data model used by the JProgressBar.
Parameters:
newModel - the BoundedRangeModel to use
See Also:
BoundedRangeModel

getValue

public int getValue()
Returns the model's current value. The value is always between the model's minimum and maximum values, inclusive.
Returns:
the value
See Also:
setValue(int), BoundedRangeModel

getMinimum

public int getMinimum()
Returns the model's minimum value.
Returns:
an int -- the model's minimum
See Also:
setMinimum(int), BoundedRangeModel

getMaximum

public int getMaximum()
Returns the model's maximum value.
Returns:
an int -- the model's maximum
See Also:
setMaximum(int), BoundedRangeModel

setValue

public void setValue(int n)
Sets the model's current value to x. If x is less than the minimum or greater than the maximum, this method throws an IllegalArgumentException and the value is not changed.

Notifies any listeners if the data changes.

Parameters:
x - the new value
See Also:
getValue(), BoundedRangeModel

setMinimum

public void setMinimum(int n)
Sets the model's minimum to x. If the maximum value or current value is outside of the new minimum, the maximum or current value is adjusted accordingly.

Notifies any listeners if the data changes.

Parameters:
x - the new minimum
See Also:
getMinimum(), addChangeListener(com.sun.java.swing.event.ChangeListener), BoundedRangeModel

setMaximum

public void setMaximum(int n)
Sets the model's maximum to x. If the minimum value or current value is outside of the new maximum, the minimum or current value is adjusted accordingly.

Notifies any listeners if the data changes.

Parameters:
x - the new maximum
See Also:
getMaximum(), addChangeListener(com.sun.java.swing.event.ChangeListener), BoundedRangeModel

getAccessibleContext

public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent
Specified by:
getAccessibleContext in interface Accessible
Returns:
the AccessibleContext of this JComponent
Overrides:
getAccessibleContext in class JComponent

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.