|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JProgressBar
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.
For further documentation and examples see How to Monitor Progress, a section in The Java Tutorial.
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 applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Inner Class Summary | |
protected class |
JProgressBar.AccessibleJProgressBar
This class implements accessibility support for the JProgressBar class. |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Inner classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent |
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
The data structure that holds the various values for the progress bar. |
protected int |
orientation
The orientation to display the progress bar. |
protected boolean |
paintBorder
Whether to display the border around the progress bar. |
protected boolean |
paintString
Whether to textually display a String on the progress bar. |
protected String |
progressString
A optional String that can be displayed on the progress bar. |
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 javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NORTH, NORTH_EAST, NORTH_WEST, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
JProgressBar()
Creates a horizontal progress bar. |
|
JProgressBar(BoundedRangeModel newModel)
Creates a horizontal progress bar, the default orientation. |
|
JProgressBar(int orient)
Creates a progress bar with the specified orientation, which can be either JProgressBar.VERTICAL or
JProgressBar.HORIZONTAL . |
|
JProgressBar(int min,
int max)
Creates a horizontal progress bar, which is the default. |
|
JProgressBar(int orient,
int min,
int max)
Creates a progress bar using the specified orientation, minimum, and maximum. |
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()
Gets the AccessibleContext associated with this JProgressBar. |
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.VERTICAL or
JProgressBar.HORIZONTAL , depending on the orientation
of the progress bar. |
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. |
protected String |
paramString()
Returns a string representation of this JProgressBar. |
void |
removeChangeListener(ChangeListener l)
Removes a ChangeListener from the button. |
void |
setBorderPainted(boolean b)
Sets whether the progress bar should paint its 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.VERTICAL or
JProgressBar.HORIZONTAL . |
void |
setString(String s)
Sets the value of the Progress String. |
void |
setStringPainted(boolean b)
Sets whether the progress bar will render a 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 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, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int orientation
protected boolean paintBorder
protected BoundedRangeModel model
protected String progressString
protected boolean paintString
protected transient ChangeEvent changeEvent
protected ChangeListener changeListener
Constructor Detail |
public JProgressBar()
JProgressBar.HORIZONTAL
.
By default, the String is set to null
and the
StringPainted is not painted.
The border is painted by default.
Uses the defaultMinimum (0) and defaultMaximum (100).
Uses the defaultMinimum for the initial value of the progress bar.public JProgressBar(int orient)
JProgressBar.VERTICAL
or
JProgressBar.HORIZONTAL
.
By default, the String is set to null
and the
StringPainted is not painted.
The border is painted by default.
Uses the defaultMinimum (0) and defaultMaximum (100).
Uses the defaultMinimum for the initial value of the progress bar.public JProgressBar(int min, int max)
null
and the
StringPainted is not painted.
The border is painted by default.
Uses the specified minimum and maximum.
Uses the specified minimum for the initial value of the progress bar.public JProgressBar(int orient, int min, int max)
null
and the
StringPainted is not painted.
The border is painted by default.
Sets the inital value of the progress bar to the specified minimum.
The BoundedRangeModel that sits underneath the progress bar
handles any issues that may arrise from improperly setting the
minimum, value, and maximum on the progress bar.BoundedRangeModel
,
setOrientation(int)
,
setBorderPainted(boolean)
,
setStringPainted(boolean)
,
setString(java.lang.String)
public JProgressBar(BoundedRangeModel newModel)
null
and the
StringPainted is not painted.
The border is painted by default.
Uses the specified BoundedRangeModel
which holds the minimum, value, and maximum.BoundedRangeModel
,
setOrientation(int)
,
setBorderPainted(boolean)
,
setStringPainted(boolean)
,
setString(java.lang.String)
Method Detail |
public int getOrientation()
JProgressBar.VERTICAL
or
JProgressBar.HORIZONTAL
, depending on the orientation
of the progress bar. The default orientation is
HORIZONTAL
.setOrientation(int)
public void setOrientation(int newOrientation)
JProgressBar.VERTICAL
or
JProgressBar.HORIZONTAL
. The default orientation
is HORIZONTAL
.newOrientation
- HORIZONTAL or VERTICALIllegalArgumentException
- if newOrientation
is an illegal valuegetOrientation()
public boolean isStringPainted()
setStringPainted(boolean)
,
setString(java.lang.String)
public void setStringPainted(boolean b)
b
- true if the progress bar will render a string.isStringPainted()
public String getString()
setString(java.lang.String)
public void setString(String s)
null
.
If you are providing a custom Progress String via this method,
you will want to ensure that you call setString() before
you call getString().
If you have provided a custom String and want to revert to
the built-in behavior, set the String back to null
.s
- the value of the percent stringgetString()
public double getPercentComplete()
public boolean isBorderPainted()
setBorderPainted(boolean)
public void setBorderPainted(boolean b)
b
- true if the progress bar paints its borderisBorderPainted()
protected void paintBorder(Graphics g)
paintBorder
in class JComponent
g
- the Graphics context within which to paint the borderJComponent.paint(java.awt.Graphics)
,
JComponent.setBorder(javax.swing.border.Border)
,
isBorderPainted()
,
setBorderPainted(boolean)
public ProgressBarUI getUI()
public void setUI(ProgressBarUI ui)
ui
- the ProgressBarUI L&F objectUIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
updateUI
in class JComponent
JComponent.updateUI()
public String getUIClassID()
getUIClassID
in class JComponent
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected ChangeListener createChangeListener()
public void addChangeListener(ChangeListener l)
l
- the ChangeListener to addpublic void removeChangeListener(ChangeListener l)
l
- the ChangeListener to removeprotected void fireStateChanged()
EventListenerList
public BoundedRangeModel getModel()
BoundedRangeModel
public void setModel(BoundedRangeModel newModel)
newModel
- the BoundedRangeModel to useBoundedRangeModel
public int getValue()
setValue(int)
,
BoundedRangeModel
public int getMinimum()
0
.setMinimum(int)
,
BoundedRangeModel
public int getMaximum()
100
.setMaximum(int)
,
BoundedRangeModel
public void setValue(int n)
x
- the new valuegetValue()
,
BoundedRangeModel.setValue(int)
public void setMinimum(int n)
Notifies any listeners if the data changes.
x
- the new minimumgetMinimum()
,
addChangeListener(javax.swing.event.ChangeListener)
,
BoundedRangeModel
public void setMaximum(int n)
Notifies any listeners if the data changes.
x
- the new maximumgetMaximum()
,
addChangeListener(javax.swing.event.ChangeListener)
,
BoundedRangeModel
protected String paramString()
null
.paramString
in class JComponent
public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
getAccessibleContext
in class JComponent
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Oracle and/or its affiliates, in the US and other countries.
Copyright © 1995, 2010 Oracle and/or its affiliates. All rights reserved.