jdk/src/share/classes/javax/swing/JProgressBar.java
Print this page
*** 20,48 ****
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
package javax.swing;
- import java.awt.Color;
import java.awt.Graphics;
import java.text.Format;
import java.text.NumberFormat;
import java.io.Serializable;
import java.io.ObjectOutputStream;
- import java.io.ObjectInputStream;
import java.io.IOException;
import javax.swing.event.*;
import javax.accessibility.*;
import javax.swing.plaf.ProgressBarUI;
-
/**
* A component that visually displays the progress of some task. As the task
* progresses towards completion, the progress bar displays the
* task's percentage of completion.
* This percentage is typically represented visually by a rectangle which
--- 20,46 ----
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing;
import java.awt.Graphics;
+ import java.beans.JavaBean;
+ import java.beans.BeanProperty;
import java.text.Format;
import java.text.NumberFormat;
import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.IOException;
import javax.swing.event.*;
import javax.accessibility.*;
import javax.swing.plaf.ProgressBarUI;
/**
* A component that visually displays the progress of some task. As the task
* progresses towards completion, the progress bar displays the
* task's percentage of completion.
* This percentage is typically represented visually by a rectangle which
*** 120,137 ****
*
* @see javax.swing.plaf.basic.BasicProgressBarUI
* @see javax.swing.BoundedRangeModel
* @see javax.swing.SwingWorker
*
- * @beaninfo
- * attribute: isContainer false
- * description: A component that displays an integer value.
- *
* @author Michael C. Albers
* @author Kathy Walrath
* @since 1.2
*/
@SuppressWarnings("serial") // Same-version serialization only
public class JProgressBar extends JComponent implements SwingConstants, Accessible
{
/**
* @see #getUIClassID
--- 118,133 ----
*
* @see javax.swing.plaf.basic.BasicProgressBarUI
* @see javax.swing.BoundedRangeModel
* @see javax.swing.SwingWorker
*
* @author Michael C. Albers
* @author Kathy Walrath
* @since 1.2
*/
+ @JavaBean(defaultProperty = "UI", description = "A component that displays an integer value.")
+ @SwingContainer(false)
@SuppressWarnings("serial") // Same-version serialization only
public class JProgressBar extends JComponent implements SwingConstants, Accessible
{
/**
* @see #getUIClassID
*** 392,408 ****
*
* @param newOrientation <code>HORIZONTAL</code> or <code>VERTICAL</code>
* @exception IllegalArgumentException if <code>newOrientation</code>
* is an illegal value
* @see #getOrientation
- *
- * @beaninfo
- * preferred: true
- * bound: true
- * attribute: visualUpdate true
- * description: Set the progress bar's orientation.
*/
public void setOrientation(int newOrientation) {
if (orientation != newOrientation) {
switch (newOrientation) {
case VERTICAL:
case HORIZONTAL:
--- 388,400 ----
*
* @param newOrientation <code>HORIZONTAL</code> or <code>VERTICAL</code>
* @exception IllegalArgumentException if <code>newOrientation</code>
* is an illegal value
* @see #getOrientation
*/
+ @BeanProperty(preferred = true, visualUpdate = true, description
+ = "Set the progress bar's orientation.")
public void setOrientation(int newOrientation) {
if (orientation != newOrientation) {
switch (newOrientation) {
case VERTICAL:
case HORIZONTAL:
*** 451,465 ****
* or might support them only when the progress bar is in determinate mode.
*
* @param b <code>true</code> if the progress bar should render a string
* @see #isStringPainted
* @see #setString
- * @beaninfo
- * bound: true
- * attribute: visualUpdate true
- * description: Whether the progress bar should render a string.
*/
public void setStringPainted(boolean b) {
//PENDING: specify that string not painted when in indeterminate mode?
// or just leave that to the L&F?
boolean oldValue = paintString;
paintString = b;
--- 443,455 ----
* or might support them only when the progress bar is in determinate mode.
*
* @param b <code>true</code> if the progress bar should render a string
* @see #isStringPainted
* @see #setString
*/
+ @BeanProperty(visualUpdate = true, description
+ = "Whether the progress bar should render a string.")
public void setStringPainted(boolean b) {
//PENDING: specify that string not painted when in indeterminate mode?
// or just leave that to the L&F?
boolean oldValue = paintString;
paintString = b;
*** 504,518 ****
*
* @param s the value of the progress string
* @see #getString
* @see #setStringPainted
* @see #isStringPainted
- * @beaninfo
- * bound: true
- * attribute: visualUpdate true
- * description: Specifies the progress string to paint
*/
public void setString(String s){
String oldValue = progressString;
progressString = s;
firePropertyChange("string", oldValue, progressString);
if (progressString == null || oldValue == null || !progressString.equals(oldValue)) {
--- 494,506 ----
*
* @param s the value of the progress string
* @see #getString
* @see #setStringPainted
* @see #isStringPainted
*/
+ @BeanProperty(visualUpdate = true, description
+ = "Specifies the progress string to paint")
public void setString(String s){
String oldValue = progressString;
progressString = s;
firePropertyChange("string", oldValue, progressString);
if (progressString == null || oldValue == null || !progressString.equals(oldValue)) {
*** 524,533 ****
--- 512,522 ----
* Returns the percent complete for the progress bar.
* Note that this number is between 0.0 and 1.0.
*
* @return the percent complete for this progress bar
*/
+ @BeanProperty(bound = false)
public double getPercentComplete() {
long span = model.getMaximum() - model.getMinimum();
double currentValue = model.getValue();
double pc = (currentValue - model.getMinimum()) / span;
return pc;
*** 536,547 ****
/**
* Returns the <code>borderPainted</code> property.
*
* @return the value of the <code>borderPainted</code> property
* @see #setBorderPainted
- * @beaninfo
- * description: Does the progress bar paint its border
*/
public boolean isBorderPainted() {
return paintBorder;
}
--- 525,534 ----
*** 554,568 ****
*
* @param b <code>true</code> if the progress bar
* should paint its border;
* otherwise, <code>false</code>
* @see #isBorderPainted
- * @beaninfo
- * bound: true
- * attribute: visualUpdate true
- * description: Whether the progress bar should paint its border.
*/
public void setBorderPainted(boolean b) {
boolean oldValue = paintBorder;
paintBorder = b;
firePropertyChange("borderPainted", oldValue, paintBorder);
if (paintBorder != oldValue) {
--- 541,553 ----
*
* @param b <code>true</code> if the progress bar
* should paint its border;
* otherwise, <code>false</code>
* @see #isBorderPainted
*/
+ @BeanProperty(visualUpdate = true, description
+ = "Whether the progress bar should paint its border.")
public void setBorderPainted(boolean b) {
boolean oldValue = paintBorder;
paintBorder = b;
firePropertyChange("borderPainted", oldValue, paintBorder);
if (paintBorder != oldValue) {
*** 599,614 ****
/**
* Sets the look-and-feel object that renders this component.
*
* @param ui a <code>ProgressBarUI</code> object
* @see UIDefaults#getUI
- * @beaninfo
- * bound: true
- * hidden: true
- * attribute: visualUpdate true
- * description: The UI object that implements the Component's LookAndFeel.
*/
public void setUI(ProgressBarUI ui) {
super.setUI(ui);
}
--- 584,596 ----
/**
* Sets the look-and-feel object that renders this component.
*
* @param ui a <code>ProgressBarUI</code> object
* @see UIDefaults#getUI
*/
+ @BeanProperty(hidden = true, visualUpdate = true, description
+ = "The UI object that implements the Component's LookAndFeel.")
public void setUI(ProgressBarUI ui) {
super.setUI(ui);
}
*** 626,639 ****
* Returns the name of the look-and-feel class that renders this component.
*
* @return the string "ProgressBarUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
- * @beaninfo
- * expert: true
- * description: A string that specifies the name of the look-and-feel class.
*/
public String getUIClassID() {
return uiClassID;
}
--- 608,620 ----
* Returns the name of the look-and-feel class that renders this component.
*
* @return the string "ProgressBarUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
*/
+ @BeanProperty(bound = false, expert = true, description
+ = "A string that specifies the name of the look-and-feel class.")
public String getUIClassID() {
return uiClassID;
}
*** 700,709 ****
--- 681,691 ----
*
* @return all of the <code>ChangeListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
+ @BeanProperty(bound = false)
public ChangeListener[] getChangeListeners() {
return listenerList.getListeners(ChangeListener.class);
}
/**
*** 750,764 ****
* Sets the data model used by the <code>JProgressBar</code>.
* Note that the {@code BoundedRangeModel}'s {@code extent} is not used,
* and is set to {@code 0}.
*
* @param newModel the <code>BoundedRangeModel</code> to use
- *
- * @beaninfo
- * expert: true
- * description: The data model used by the JProgressBar.
*/
public void setModel(BoundedRangeModel newModel) {
// PENDING(???) setting the same model to multiple bars is broken; listeners
BoundedRangeModel oldModel = getModel();
if (newModel != oldModel) {
--- 732,744 ----
* Sets the data model used by the <code>JProgressBar</code>.
* Note that the {@code BoundedRangeModel}'s {@code extent} is not used,
* and is set to {@code 0}.
*
* @param newModel the <code>BoundedRangeModel</code> to use
*/
+ @BeanProperty(bound = false, expert = true, description
+ = "The data model used by the JProgressBar.")
public void setModel(BoundedRangeModel newModel) {
// PENDING(???) setting the same model to multiple bars is broken; listeners
BoundedRangeModel oldModel = getModel();
if (newModel != oldModel) {
*** 839,852 ****
*
* @param n the new value
* @see #getValue
* @see #addChangeListener
* @see BoundedRangeModel#setValue
- * @beaninfo
- * preferred: true
- * description: The progress bar's current value.
*/
public void setValue(int n) {
BoundedRangeModel brm = getModel();
int oldValue = brm.getValue();
brm.setValue(n);
--- 819,831 ----
*
* @param n the new value
* @see #getValue
* @see #addChangeListener
* @see BoundedRangeModel#setValue
*/
+ @BeanProperty(bound = false, preferred = true, description
+ = "The progress bar's current value.")
public void setValue(int n) {
BoundedRangeModel brm = getModel();
int oldValue = brm.getValue();
brm.setValue(n);
*** 872,885 ****
*
* @param n the new minimum
* @see #getMinimum
* @see #addChangeListener
* @see BoundedRangeModel#setMinimum
- * @beaninfo
- * preferred: true
- * description: The progress bar's minimum value.
*/
public void setMinimum(int n) { getModel().setMinimum(n); }
/**
* Sets the progress bar's maximum value
* (stored in the progress bar's data model) to <code>n</code>.
--- 851,863 ----
*
* @param n the new minimum
* @see #getMinimum
* @see #addChangeListener
* @see BoundedRangeModel#setMinimum
*/
+ @BeanProperty(bound = false, preferred = true, description
+ = "The progress bar's minimum value.")
public void setMinimum(int n) { getModel().setMinimum(n); }
/**
* Sets the progress bar's maximum value
* (stored in the progress bar's data model) to <code>n</code>.
*** 893,906 ****
*
* @param n the new maximum
* @see #getMaximum
* @see #addChangeListener
* @see BoundedRangeModel#setMaximum
- * @beaninfo
- * preferred: true
- * description: The progress bar's maximum value.
*/
public void setMaximum(int n) { getModel().setMaximum(n); }
/**
* Sets the <code>indeterminate</code> property of the progress bar,
* which determines whether the progress bar is in determinate
--- 871,883 ----
*
* @param n the new maximum
* @see #getMaximum
* @see #addChangeListener
* @see BoundedRangeModel#setMaximum
*/
+ @BeanProperty(bound = false, preferred = true, description
+ = "The progress bar's maximum value.")
public void setMaximum(int n) { getModel().setMaximum(n); }
/**
* Sets the <code>indeterminate</code> property of the progress bar,
* which determines whether the progress bar is in determinate
*** 923,938 ****
*
* @see #isIndeterminate
* @see javax.swing.plaf.basic.BasicProgressBarUI
*
* @since 1.4
- *
- * @beaninfo
- * bound: true
- * attribute: visualUpdate true
- * description: Set whether the progress bar is indeterminate (true)
- * or normal (false).
*/
public void setIndeterminate(boolean newValue) {
boolean oldValue = indeterminate;
indeterminate = newValue;
firePropertyChange("indeterminate", oldValue, indeterminate);
--- 900,909 ----
*** 943,957 ****
*
* @return the value of the <code>indeterminate</code> property
* @see #setIndeterminate
*
* @since 1.4
- *
- * @beaninfo
- * description: Is the progress bar indeterminate (true)
- * or normal (false)?
*/
public boolean isIndeterminate() {
return indeterminate;
}
--- 914,926 ----
*
* @return the value of the <code>indeterminate</code> property
* @see #setIndeterminate
*
* @since 1.4
*/
+ @BeanProperty(bound = false, description
+ = "Is the progress bar indeterminate (true) or normal (false)?")
public boolean isIndeterminate() {
return indeterminate;
}
*** 1011,1024 ****
* <code>AccessibleJProgressBar</code>.
* A new <code>AccessibleJProgressBar</code> instance is created if necessary.
*
* @return an <code>AccessibleJProgressBar</code> that serves as the
* <code>AccessibleContext</code> of this <code>JProgressBar</code>
- * @beaninfo
- * expert: true
- * description: The AccessibleContext associated with this ProgressBar.
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJProgressBar();
}
return accessibleContext;
--- 980,992 ----
* <code>AccessibleJProgressBar</code>.
* A new <code>AccessibleJProgressBar</code> instance is created if necessary.
*
* @return an <code>AccessibleJProgressBar</code> that serves as the
* <code>AccessibleContext</code> of this <code>JProgressBar</code>
*/
+ @BeanProperty(bound = false, expert = true, description
+ = "The AccessibleContext associated with this ProgressBar.")
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJProgressBar();
}
return accessibleContext;