List of usage examples for com.google.gwt.user.client.ui HTML HTML
protected HTML(Element element)
From source file:com.google.gerrit.client.account.RegisterScreen.java
License:Apache License
@Override protected void onInitUI() { super.onInitUI(); setPageTitle(Util.C.welcomeToGerritCodeReview()); final FlowPanel formBody = new FlowPanel(); final FlowPanel contactGroup = new FlowPanel(); contactGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection()); contactGroup.add(new SmallHeading(Util.C.welcomeReviewContact())); final HTML whereFrom = new HTML(Util.C.welcomeContactFrom()); whereFrom.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain()); contactGroup.add(whereFrom);/* w w w.j a v a 2 s. co m*/ contactGroup.add(new ContactPanelShort() { @Override protected void display(final Account userAccount) { super.display(userAccount); if ("".equals(nameTxt.getText())) { // No name? Encourage the user to provide us something. // nameTxt.setFocus(true); save.setEnabled(true); } } }); formBody.add(contactGroup); if (Gerrit.getUserAccount().getUserName() == null && Gerrit.getConfig().canEdit(FieldName.USER_NAME)) { final FlowPanel fp = new FlowPanel(); fp.setStyleName(Gerrit.RESOURCES.css().registerScreenSection()); fp.add(new SmallHeading(Util.C.welcomeUsernameHeading())); final Grid userInfo = new Grid(1, 2); final CellFormatter fmt = userInfo.getCellFormatter(); userInfo.setStyleName(Gerrit.RESOURCES.css().infoBlock()); userInfo.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock()); fp.add(userInfo); fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost()); fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost()); fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().bottomheader()); UsernameField field = new UsernameField(); if (LocaleInfo.getCurrentLocale().isRTL()) { userInfo.setText(0, 1, Util.C.userName()); userInfo.setWidget(0, 0, field); fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().header()); } else { userInfo.setText(0, 0, Util.C.userName()); userInfo.setWidget(0, 1, field); fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().header()); } formBody.add(fp); } if (Gerrit.getConfig().getSshdAddress() != null) { final FlowPanel sshKeyGroup = new FlowPanel(); sshKeyGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection()); sshKeyGroup.add(new SmallHeading(Util.C.welcomeSshKeyHeading())); final HTML whySshKey = new HTML(Util.C.welcomeSshKeyText()); whySshKey.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain()); sshKeyGroup.add(whySshKey); sshKeyGroup.add(new SshPanel() { { setKeyTableVisible(false); } }); formBody.add(sshKeyGroup); } final FlowPanel choices = new FlowPanel(); choices.setStyleName(Gerrit.RESOURCES.css().registerScreenNextLinks()); if (Gerrit.getConfig().isUseContributorAgreements()) { final FlowPanel agreementGroup = new FlowPanel(); agreementGroup.setStyleName(Gerrit.RESOURCES.css().registerScreenSection()); agreementGroup.add(new SmallHeading(Util.C.welcomeAgreementHeading())); final HTML whyAgreement = new HTML(Util.C.welcomeAgreementText()); whyAgreement.setStyleName(Gerrit.RESOURCES.css().registerScreenExplain()); agreementGroup.add(whyAgreement); choices.add(new InlineHyperlink(Util.C.newAgreement(), PageLinks.SETTINGS_NEW_AGREEMENT)); choices.add(new InlineHyperlink(Util.C.welcomeAgreementLater(), nextToken)); formBody.add(agreementGroup); } else { choices.add(new InlineHyperlink(Util.C.welcomeContinue(), nextToken)); } formBody.add(choices); final FormPanel form = new FormPanel(); form.add(formBody); add(form); }
From source file:com.google.gerrit.client.account.SshHostKeyPanel.java
License:Apache License
SshHostKeyPanel(final SshHostKey info) { final FlowPanel body = new FlowPanel(); body.setStyleName(Gerrit.RESOURCES.css().sshHostKeyPanel()); body.add(new SmallHeading(Util.C.sshHostKeyTitle())); {/*from w w w . j a va 2 s. c o m*/ final Label fpLbl = new Label(Util.C.sshHostKeyFingerprint()); fpLbl.setStyleName(Gerrit.RESOURCES.css().sshHostKeyPanelHeading()); body.add(fpLbl); final Label fpVal = new Label(info.getFingerprint()); fpVal.setStyleName(Gerrit.RESOURCES.css().sshHostKeyPanelFingerprintData()); body.add(fpVal); } { final HTML hdr = new HTML(Util.C.sshHostKeyKnownHostEntry()); hdr.setStyleName(Gerrit.RESOURCES.css().sshHostKeyPanelHeading()); body.add(hdr); final CopyableLabel lbl; lbl = new CopyableLabel(info.getHostIdent() + " " + info.getHostKey()); lbl.setPreviewText(SshPanel.elide(lbl.getText(), 80)); lbl.addStyleName(Gerrit.RESOURCES.css().sshHostKeyPanelKnownHostEntry()); body.add(lbl); } initWidget(body); }
From source file:com.google.gerrit.client.account.SshPanel.java
License:Apache License
SshPanel() { final FlowPanel body = new FlowPanel(); showAddKeyBlock = new Button(Util.C.buttonShowAddSshKey()); showAddKeyBlock.addClickHandler(new ClickHandler() { @Override/*from w w w . j av a2s.co m*/ public void onClick(final ClickEvent event) { showAddKeyBlock(true); } }); keys = new SshKeyTable(); body.add(keys); { final FlowPanel fp = new FlowPanel(); deleteKey = new Button(Util.C.buttonDeleteSshKey()); deleteKey.setEnabled(false); deleteKey.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { keys.deleteChecked(); } }); fp.add(deleteKey); fp.add(showAddKeyBlock); body.add(fp); } addKeyBlock = new VerticalPanel(); addKeyBlock.setVisible(false); addKeyBlock.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel()); addKeyBlock.add(new SmallHeading(Util.C.addSshKeyPanelHeader())); final ComplexDisclosurePanel addSshKeyHelp = new ComplexDisclosurePanel(Util.C.addSshKeyHelpTitle(), false); addSshKeyHelp.setContent(new HTML(Util.C.addSshKeyHelp())); addKeyBlock.add(addSshKeyHelp); addTxt = new NpTextArea(); addTxt.setVisibleLines(12); addTxt.setCharacterWidth(80); addTxt.setSpellCheck(false); addKeyBlock.add(addTxt); final HorizontalPanel buttons = new HorizontalPanel(); addKeyBlock.add(buttons); clearNew = new Button(Util.C.buttonClearSshKeyInput()); clearNew.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { addTxt.setText(""); addTxt.setFocus(true); } }); buttons.add(clearNew); addNew = new Button(Util.C.buttonAddSshKey()); addNew.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { doAddNew(); } }); buttons.add(addNew); closeAddKeyBlock = new Button(Util.C.buttonCloseAddSshKey()); closeAddKeyBlock.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { showAddKeyBlock(false); } }); buttons.add(closeAddKeyBlock); buttons.setCellWidth(closeAddKeyBlock, "100%"); buttons.setCellHorizontalAlignment(closeAddKeyBlock, HasHorizontalAlignment.ALIGN_RIGHT); body.add(addKeyBlock); serverKeys = new FlowPanel(); body.add(serverKeys); initWidget(body); }
From source file:com.google.gerrit.client.auth.openid.OpenIdSignInDialog.java
License:Apache License
public OpenIdSignInDialog(final SignInMode requestedMode, final String token, final String initialErrorMsg) { super(requestedMode, token); formBody = new FlowPanel(); formBody.setStyleName(OpenIdResources.I.css().loginForm()); form = new FormPanel(); form.setMethod(FormPanel.METHOD_GET); form.addSubmitHandler(this); form.add(formBody);/*from w ww . j a va 2s. c o m*/ redirectBody = new FlowPanel(); redirectBody.setVisible(false); redirectForm = new FormPanel(); redirectForm.add(redirectBody); panelWidget = new FlowPanel(); panelWidget.add(form); panelWidget.add(redirectForm); add(panelWidget); createHeaderLogo(); createHeaderText(); createErrorBox(); createIdentBox(); link(OpenIdUrls.URL_GOOGLE, OpenIdUtil.C.nameGoogle(), OpenIdResources.I.iconGoogle()); link(OpenIdUrls.URL_YAHOO, OpenIdUtil.C.nameYahoo(), OpenIdResources.I.iconYahoo()); if (initialErrorMsg != null) { showError(initialErrorMsg); } formBody.add(new HTML(OpenIdUtil.C.whatIsOpenIDHtml())); }
From source file:com.google.gerrit.client.NotSignedInDialog.java
License:Apache License
public NotSignedInDialog() { super(/* auto hide */false, /* modal */true); setGlassEnabled(true);//from w ww . j a v a 2s . c o m setText(Gerrit.C.notSignedInTitle()); final FlowPanel buttons = new FlowPanel(); signin = new Button(); signin.setText(Gerrit.C.menuSignIn()); signin.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { buttonClicked = true; hide(); Gerrit.doSignIn(History.getToken()); } }); buttons.add(signin); final Button close = new Button(); DOM.setStyleAttribute(close.getElement(), "marginLeft", "200px"); close.setText(Gerrit.C.signInDialogClose()); close.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { buttonClicked = true; Gerrit.deleteSessionCookie(); hide(); } }); buttons.add(close); final FlowPanel center = new FlowPanel(); center.add(new HTML(Gerrit.C.notSignedInBody())); center.add(buttons); add(center); center.setWidth("400px"); addCloseHandler(this); }
From source file:com.google.gwt.demos.bulkloadingtable.client.BulkLoadingTableDemo.java
License:Apache License
public void onModuleLoad() { panel = new VerticalPanel(); RootPanel.get().add(panel);/* w w w. ja v a 2 s . c om*/ panel.add( new HTML("<h2>A very boring demo showing the speed difference of using bulk loading tables.</h2>")); panel.add(new Label("Number of rows")); final TextBox rows = new TextBox(); panel.add(rows); rows.setText(numRows + ""); rows.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { numRows = Integer.parseInt(rows.getText().trim()); } }); panel.add(new Label("Number of columns")); final TextBox columns = new TextBox(); panel.add(columns); columns.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { numColumns = Integer.parseInt(columns.getText()); } }); columns.setText(numColumns + ""); panel.add(new HTML( "<p/><p/><b>Clear Table now </b> (clearing will also happen if the buttons are clicked below)")); panel.add(new Button("Go", new ClickListener() { public void onClick(Widget sender) { clearTable(); } })); panel.add(new HTML("<p/><p/><b> Use the traditional FlexTable API</b>")); Button flexTableAPI = new Button("Go", new ClickListener() { public void onClick(Widget sender) { clearTable(); long milli = System.currentTimeMillis(); FlexTable newTable = new FlexTable(); usingFlexTableAPI(newTable); finishTable(newTable, milli); } }); panel.add(flexTableAPI); panel.add(new HTML("<p/><p/><b> Use the traditional Grid API</b>")); Button gridAPI = new Button("Go", new ClickListener() { public void onClick(Widget sender) { clearTable(); long milli = System.currentTimeMillis(); Grid newTable = new Grid(); usingGridAPI(newTable); finishTable(newTable, milli); } }); panel.add(gridAPI); panel.add(new HTML("<p/><p/><b> Use the attached Grid API</b>")); Button detachedGridAPI = new Button("Go", new ClickListener() { public void onClick(Widget sender) { clearTable(); long milli = System.currentTimeMillis(); Grid table = new Grid(); curTable = table; table.setBorderWidth(2); panel.add(table); usingGridAPI(table); log("Finished in " + (System.currentTimeMillis() - milli) + " milliseconds"); } }); panel.add(detachedGridAPI); panel.add(new HTML("<p/><p/><b> Use Async BulkLoadedTable API</b>")); Button asyncAPI = new Button("Go", new ClickListener() { public void onClick(Widget sender) { clearTable(); long milli = System.currentTimeMillis(); FlexTable table = new FlexTable(); usingBulkLoadedTableAPI(table, milli); } }); panel.add(asyncAPI); panel.add(new HTML("<p/><p/><b> Use the PreloadedTable API</b>")); Button pendingAPI = new Button("Go", new ClickListener() { public void onClick(Widget sender) { clearTable(); long milli = System.currentTimeMillis(); PreloadedTable table = new PreloadedTable(); usingPreloadedTableAPI(table); finishTable(table, milli); } }); panel.add(pendingAPI); }
From source file:com.google.gwt.demos.fasttree.client.FastTreeDemo.java
License:Apache License
public void report(String s) { RootPanel.get().add(new HTML(s)); }
From source file:com.google.gwt.demos.glasspanel.client.GlassPanelDemo.java
License:Apache License
public void onModuleLoad2() { RootPanel.get().add(new HTML("<code>$doc.compatMode = <b>" + getCompatMode() + "</b></code>")); redAbsolutePanel = new AbsolutePanel(); redAbsolutePanel.setPixelSize(130, 130); RootPanel.get().add(redAbsolutePanel, 500, 150); redAbsolutePanel.add(new HTML( "This red GlassPanel was created<br>" + "with <code>autoHide</code> set to <code>false</code>.")); greenAbsolutePanel = RootPanel.get("xyz"); workaroundIssue1813(greenAbsolutePanel.getElement()); greenAbsolutePanel.add(new HTML("Click or press <code>ESC</code> once<br>" + "to remove the gray GlassPanel.<br><br>" + "Click or press <code>ESC</code> a second<br>" + "time to remove this green GlassPanel.")); Button buttonBodyDefault = new Button("BODY setSize(\"\", \"\")"); buttonBodyDefault.addClickListener(new ClickListener() { public void onClick(Widget sender) { removeGlassPanel();/*from w w w. j av a 2 s. c om*/ RootPanel.get().setSize("", ""); resetGlassPanels(); } }); Button buttonBodyLarge = new Button("BODY setSize(\"1000px\", \"1000px\")"); buttonBodyLarge.addClickListener(new ClickListener() { public void onClick(Widget sender) { removeGlassPanel(); RootPanel.get().setSize("1000px", "1000px"); resetGlassPanels(); } }); Button buttonHTMLDefault = new Button("HTML setSize(\"\", \"\")"); buttonHTMLDefault.addClickListener(new ClickListener() { public void onClick(Widget sender) { removeGlassPanel(); Element htmlElement = DOM.getParent(RootPanel.getBodyElement()); DOM.setStyleAttribute(htmlElement, "width", ""); DOM.setStyleAttribute(htmlElement, "height", ""); resetGlassPanels(); } }); Button buttonHTMLLarge = new Button("HTML setSize(\"2000px\", \"2000px\")"); buttonHTMLLarge.addClickListener(new ClickListener() { public void onClick(Widget sender) { removeGlassPanel(); Element htmlElement = DOM.getParent(RootPanel.getBodyElement()); DOM.setStyleAttribute(htmlElement, "width", "2000px"); DOM.setStyleAttribute(htmlElement, "height", "2000px"); resetGlassPanels(); } }); Button buttonScrollingEnable = new Button("Window.enableScrolling(true)"); buttonScrollingEnable.addClickListener(new ClickListener() { public void onClick(Widget sender) { removeGlassPanel(); Window.enableScrolling(true); resetGlassPanels(); } }); Button buttonScrollingDisable = new Button("Window.enableScrolling(false)"); buttonScrollingDisable.addClickListener(new ClickListener() { public void onClick(Widget sender) { removeGlassPanel(); Window.enableScrolling(false); resetGlassPanels(); } }); FlexTable buttonTable = new FlexTable(); buttonTable.addStyleName("buttons"); RootPanel.get().add(buttonTable, 100, 50); buttonTable.setWidget(0, 0, buttonBodyDefault); buttonTable.setWidget(0, 1, buttonBodyLarge); buttonTable.setWidget(1, 0, buttonHTMLDefault); buttonTable.setWidget(1, 1, buttonHTMLLarge); buttonTable.setWidget(2, 0, buttonScrollingEnable); buttonTable.setWidget(2, 1, buttonScrollingDisable); resetGlassPanels(); }
From source file:com.google.gwt.demos.progressbar.client.ProgressBarDemo.java
License:Apache License
/** * This is the entry point method./*from w w w .ja v a2s .c o m*/ */ public void onModuleLoad() { // Setup the progress bars exampleBar2.setTextVisible(false); exampleBar2.addStyleName("gwt-ProgressBar-thin"); // Place everything in a nice looking grid Grid grid = new Grid(7, 3); grid.setBorderWidth(1); grid.setCellPadding(3); // Set the current progress final TextBox curBox = new TextBox(); curBox.setText("0.0"); grid.setWidget(0, 1, curBox); grid.setHTML(0, 2, "The current progress."); grid.setWidget(0, 0, new Button("Set Progress", new ClickListener() { public void onClick(Widget sender) { simulationTimer.cancel(); mainProgressBar.setProgress(new Float(curBox.getText()).floatValue()); } })); // Set the minimum progress final TextBox minBox = new TextBox(); minBox.setText(mainProgressBar.getMinProgress() + ""); grid.setWidget(1, 1, minBox); grid.setHTML(1, 2, "The minimum progress progress."); grid.setWidget(1, 0, new Button("Set Min Progress", new ClickListener() { public void onClick(Widget sender) { simulationTimer.cancel(); mainProgressBar.setMinProgress(new Float(minBox.getText()).floatValue()); } })); // Set the maximum progress final TextBox maxBox = new TextBox(); maxBox.setText(mainProgressBar.getMaxProgress() + ""); grid.setWidget(2, 1, maxBox); grid.setHTML(2, 2, "The maximum progress."); grid.setWidget(2, 0, new Button("Set Max Progress", new ClickListener() { public void onClick(Widget sender) { simulationTimer.cancel(); mainProgressBar.setMaxProgress(new Float(maxBox.getText()).floatValue()); } })); // Show or hide the text final HTML textVisibleLabel = new HTML("visible"); grid.setWidget(3, 1, textVisibleLabel); grid.setHTML(3, 2, "Show or hide the text in the progress bar."); grid.setWidget(3, 0, new Button("Toggle Text", new ClickListener() { public void onClick(Widget sender) { if (mainProgressBar.isTextVisible()) { textVisibleLabel.setHTML("hidden"); mainProgressBar.setTextVisible(false); } else { textVisibleLabel.setHTML("visible"); mainProgressBar.setTextVisible(true); } } })); // Add the default text option final HTML defaultTextLabel = new HTML("custom"); grid.setWidget(4, 1, defaultTextLabel); grid.setHTML(4, 2, "Override the format of the text with a custom" + "format."); grid.setWidget(4, 0, new Button("Toggle Custom Text", new ClickListener() { public void onClick(Widget sender) { if (useCustomText) { defaultTextLabel.setHTML("default"); useCustomText = false; mainProgressBar.setProgress(mainProgressBar.getProgress()); } else { defaultTextLabel.setHTML("custom"); useCustomText = true; mainProgressBar.setProgress(mainProgressBar.getProgress()); } } })); // Add static resize timer methods final HTML resizeCheckLabel = new HTML("enabled"); grid.setWidget(5, 1, resizeCheckLabel); grid.setHTML(5, 2, "When resize checking is enabled, a Timer will " + "periodically check if the Widget's dimensions have changed. If " + "they change, the widget will be redrawn."); grid.setWidget(5, 0, new Button("Toggle Resize Checking", new ClickListener() { public void onClick(Widget sender) { if (ResizableWidgetCollection.get().isResizeCheckingEnabled()) { ResizableWidgetCollection.get().setResizeCheckingEnabled(false); resizeCheckLabel.setHTML("disabled"); } else { ResizableWidgetCollection.get().setResizeCheckingEnabled(true); resizeCheckLabel.setHTML("enabled"); } } })); // 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 widget. 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) { mainProgressBar.setWidth(widthBox.getText()); } })); // Add all components to the page RootPanel.get().add(mainProgressBar); RootPanel.get().add(new HTML("<BR>")); RootPanel.get().add(grid); RootPanel.get().add(new HTML("<BR>Additional Progress Bars:<BR>")); RootPanel.get().add(exampleBar1); RootPanel.get().add(new HTML("<BR>")); RootPanel.get().add(exampleBar2); // Simulate progress over time simulateProgress(); }
From source file:com.google.gwt.demos.sliderbar.client.SliderBarDemo.java
License:Apache License
/** * This is the entry point method./*from w w w . j a v a 2 s .c o m*/ */ 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); grid.setHTML(7, 2, "Override the format of the labels with a custom" + "format."); grid.setWidget(7, 0, new Button("Toggle Custom Text", new ClickListener() { public void onClick(Widget sender) { if (useCustomText) { defaultTextLabel.setHTML("default"); useCustomText = false; mainSliderBar.redraw(); } else { defaultTextLabel.setHTML("custom"); useCustomText = true; mainSliderBar.redraw(); } } })); // Add static resize timer methods final HTML resizeCheckLabel = new HTML("enabled"); grid.setWidget(8, 1, resizeCheckLabel); grid.setHTML(8, 2, "When resize checking is enabled, a Timer will " + "periodically check if the Widget's dimensions have changed. If " + "they change, the widget will be redrawn."); grid.setWidget(8, 0, new Button("Toggle Resize Checking", new ClickListener() { public void onClick(Widget sender) { if (ResizableWidgetCollection.get().isResizeCheckingEnabled()) { ResizableWidgetCollection.get().setResizeCheckingEnabled(false); resizeCheckLabel.setHTML("disabled"); } else { ResizableWidgetCollection.get().setResizeCheckingEnabled(true); resizeCheckLabel.setHTML("enabled"); } } })); // Add elements to page RootPanel.get().add(mainSliderBar); RootPanel.get().add(new HTML("<BR>")); RootPanel.get().add(grid); RootPanel.get().add(new HTML("<BR>Additional SliderBars:<BR>")); RootPanel.get().add(exampleBar1); RootPanel.get().add(new HTML("<BR>")); RootPanel.get().add(exampleBar2); }