/**
* This is the entry point method.
*/
public void onModuleLoad() {
// TextBox to display or set current value
final TextBox curBox = new TextBox();
// Setup the slider bars
mainSliderBar.setStepSize(5.0);
mainSliderBar.setCurrentValue(50.0);
mainSliderBar.setNumTicks(10);
mainSliderBar.setNumLabels(5);
mainSliderBar.addChangeListener(new ChangeListener() {
public void onChange(Widget sender) {
curBox.setText(mainSliderBar.getCurrentValue() + "");
}
});
exampleBar1.setStepSize(0.1);
exampleBar1.setCurrentValue(0.5);
exampleBar1.setNumTicks(10);
exampleBar1.setNumLabels(10);
exampleBar2.setStepSize(1.0);
exampleBar2.setCurrentValue(13.0);
exampleBar2.setNumTicks(25);
exampleBar2.setNumLabels(25);
// Place everything in a nice looking grid
Grid grid = new Grid(9, 3);
grid.setBorderWidth(1);
grid.setCellPadding(3);
// The type of text to display
final HTML defaultTextLabel = new HTML("custom");
// Set the current slider position
curBox.setText("50.0");
grid.setWidget(0, 1, curBox);
grid.setHTML(0, 2, "The current value of the knob.");
grid.setWidget(0, 0, new Button("Set Current Value", new ClickListener() {
public void onClick(Widget sender) {
mainSliderBar.setCurrentValue(new Float(curBox.getText()).floatValue());
}
}));
// Set the minimum value
final TextBox minBox = new TextBox();
minBox.setText("0.0");
grid.setWidget(1, 1, minBox);
grid.setHTML(1, 2, "The lower bounds (minimum) of the range.");
grid.setWidget(1, 0, new Button("Set Min Value", new ClickListener() {
public void onClick(Widget sender) {
mainSliderBar.setMinValue(new Float(minBox.getText()).floatValue());
}
}));
// Set the maximum value
final TextBox maxBox = new TextBox();
maxBox.setText("100.0");
grid.setWidget(2, 1, maxBox);
grid.setHTML(2, 2, "The upper bounds (maximum) of the range.");
grid.setWidget(2, 0, new Button("Set Max Value", new ClickListener() {
public void onClick(Widget sender) {
mainSliderBar.setMaxValue(new Float(maxBox.getText()).floatValue());
}
}));
// Set the step size
final TextBox stepSizeBox = new TextBox();
stepSizeBox.setText("1.0");
grid.setWidget(3, 1, stepSizeBox);
grid.setHTML(3, 2, "The increments between each knob position.");
grid.setWidget(3, 0, new Button("Set Step Size", new ClickListener() {
public void onClick(Widget sender) {
mainSliderBar.setStepSize(new Float(stepSizeBox.getText()).floatValue());
}
}));
// Set the number of tick marks
final TextBox numTicksBox = new TextBox();
numTicksBox.setText("10");
grid.setWidget(4, 1, numTicksBox);
grid.setHTML(4, 2,
"The vertical black lines along the range of value. Note that the "
+ "number of ticks is actually one more than the number you "
+ "specify, so setting the number of ticks to one will display a "
+ "tick at each end of the slider.");
grid.setWidget(4, 0, new Button("Set Num Ticks", new ClickListener() {
public void onClick(Widget sender) {
mainSliderBar.setNumTicks(new Integer(numTicksBox.getText()).intValue());
}
}));
// Set the number of labels
final TextBox numLabelsBox = new TextBox();
numLabelsBox.setText("5");
grid.setWidget(5, 1, numLabelsBox);
grid.setHTML(5, 2, "The labels above the ticks.");
grid.setWidget(5, 0, new Button("Set Num Labels", new ClickListener() {
public void onClick(Widget sender) {
mainSliderBar.setNumLabels(new Integer(numLabelsBox.getText()).intValue());
}
}));
// Create a form to set width of element
final TextBox widthBox = new TextBox();
widthBox.setText("50%");
grid.setWidget(6, 1, widthBox);
grid.setHTML(6, 2, "Set the width of the slider. Use this to see how "
+ "resize checking detects the new dimensions and redraws the widget.");
grid.setWidget(6, 0, new Button("Set Width", new ClickListener() {
public void onClick(Widget sender) {
mainSliderBar.setWidth(widthBox.getText());
}
}));
// Add the default text option
grid.setWidget(7, 1, defaultTextLabel);