|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Panel
com.google.gwt.user.client.ui.ComplexPanel
com.google.gwt.user.client.ui.CellPanel
com.google.gwt.user.client.ui.VerticalPanel
org.gwtwidgets.client.ui.ProgressBar
public class ProgressBar
A simple progress bar that uses table elements to show progress and with a basic time remaining calculation built in.
You can optionally display some text above the progress bar and/or display time remaining underneath the progress bar. To control the display of those features, set the options in the constructor as shown in the following usage example:
final ProgressBar progressBar = new ProgressBar(20
,ProgressBar.SHOW_TIME_REMAINING
+ProgressBar.SHOW_TEXT);
progressBar.setText("Doing something...");
RootPanel.get().add(progressBar);
Timer t = new Timer() {
public void run() {
int progress = progressBar.getProgress()+4;
if (progress>100) cancel();
progressBar.setProgress(progress);
}
};
t.scheduleRepeating(1000);
How the time remaining is displayed can be controlled by setting the relevant messages using the language of your choice.
The default setting for the messages are as follows:
setSecondsMessage("Time remaining: {0} Seconds");
setMinutesMessage("Time remaining: {0} Minutes");
setHoursMessage("Time remaining: {0} Hours");
To reset the time remaining/set the start time, simply set the progress to zero.
Some basic CSS styling is available to control the text, border around the progress bar itself and the colour of the progress bar elements.
.progressbar-text {
font-weight: bold;
}
.progressbar-remaining {
font-size: 12px;
font-style: italic;
}
.progressbar-outer {
border: 1px solid black;
}
.progressbar-inner {
border: 1px solid black;
margin: 1px;
}
.progressbar-bar {
width: 5px;
height: 15px;
margin: 1px;
}
.progressbar-fullbar {
background: blue;
}
.progressbar-blankbar {
background: #eee;
}
You can take advantage of the default style by adding the following to the head of your HTML page.
<link rel="stylesheet" type="text/css" href="style/gwl-progressBar.css">
This style sheet also has two additional styles which you can use by adding the stye name to the widget. You can use either one of these, or use both combined.
ProgressBar progressBar = new ProgressBar(20);
progressBar.addStyleName("progressbar-solid");
progressBar.addStyleName("progressbar-noborder");
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment |
|---|
com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant |
| Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasVerticalAlignment |
|---|
com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant |
| Field Summary | |
|---|---|
static int |
SHOW_TEXT
Option to show text label above progress bar |
static int |
SHOW_TIME_REMAINING
Option to show time remaining |
| Fields inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment |
|---|
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT |
| Fields inherited from interface com.google.gwt.user.client.ui.HasVerticalAlignment |
|---|
ALIGN_BOTTOM, ALIGN_MIDDLE, ALIGN_TOP |
| Constructor Summary | |
|---|---|
ProgressBar(int elements)
Constructor without options |
|
ProgressBar(int elements,
int options)
Base constructor for this widget |
|
| Method Summary | |
|---|---|
java.lang.String |
getHoursMessage()
Get the message used to format the time remaining text for hours |
java.lang.String |
getMinutesMessage()
Get the message used to format the time remaining text for minutes |
int |
getProgress()
Get the current progress as a percentage |
java.lang.String |
getSecondsMessage()
Get the message used to format the time remaining text for seconds |
java.lang.String |
getText()
Get the text displayed above the progress bar |
void |
setHoursMessage(java.lang.String hoursMessage)
Set the message used to format the time remaining text below the progress bar. |
void |
setMinutesMessage(java.lang.String minutesMessage)
Set the message used to format the time remaining text below the progress bar. |
void |
setProgress(int percentage)
Set the current progress as a percentage |
void |
setSecondsMessage(java.lang.String secondsMessage)
Set the message used to format the time remaining text below the progress bar. |
void |
setText(java.lang.String text)
Set the text displayed above the progress bar |
| Methods inherited from class com.google.gwt.user.client.ui.VerticalPanel |
|---|
add, getHorizontalAlignment, getVerticalAlignment, insert, remove, setHorizontalAlignment, setVerticalAlignment |
| Methods inherited from class com.google.gwt.user.client.ui.CellPanel |
|---|
getBody, getSpacing, getTable, setBorderWidth, setCellHeight, setCellHorizontalAlignment, setCellHorizontalAlignment, setCellVerticalAlignment, setCellVerticalAlignment, setCellWidth, setSpacing |
| Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel |
|---|
add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, getChildren, getWidget, getWidgetCount, getWidgetIndex, insert, insert, iterator, remove |
| Methods inherited from class com.google.gwt.user.client.ui.Panel |
|---|
adopt, adopt, clear, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan |
| Methods inherited from class com.google.gwt.user.client.ui.Widget |
|---|
getParent, isAttached, onAttach, onBrowserEvent, onDetach, removeFromParent, setElement |
| Methods inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int SHOW_TEXT
public static final int SHOW_TIME_REMAINING
| Constructor Detail |
|---|
public ProgressBar(int elements,
int options)
elements - The number of elements (bars) to show on the progress baroptions - The display options for the progress barpublic ProgressBar(int elements)
elements - The number of elements (bars) to show on the progress bar| Method Detail |
|---|
public void setProgress(int percentage)
percentage - Set current percentage for the progress barpublic int getProgress()
public java.lang.String getText()
public void setText(java.lang.String text)
text - the text to setpublic java.lang.String getHoursMessage()
public void setHoursMessage(java.lang.String hoursMessage)
hoursMessage - the hours message to setpublic java.lang.String getMinutesMessage()
public void setMinutesMessage(java.lang.String minutesMessage)
minutesMessage - the minutes message to setpublic java.lang.String getSecondsMessage()
public void setSecondsMessage(java.lang.String secondsMessage)
secondsMessage - the secondsMessage to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||