List of usage examples for com.google.gwt.user.client.ui HTML HTML
protected HTML(Element element)
From source file:com.google.gwt.gears.sample.workerpooldemo.client.WorkerPoolDemo.java
License:Apache License
private Widget buildControlPanel() { VerticalPanel outerPanel = new VerticalPanel(); DecoratorPanel tableWrapper = new DecoratorPanel(); FlexTable resultTable = new FlexTable(); numDigitsListBox.addItem("1,000", "1000"); numDigitsListBox.addItem("5,000", "5000"); numDigitsListBox.addItem("10,000", "10000"); numDigitsListBox.addItem("20,000", "20000"); numDigitsListBox.addItem("100,000", "100000"); buildControlPanelRow(resultTable, "Number of Digits to compute: ", numDigitsListBox); buildControlPanelRow(resultTable, "Execute calculation using:", syncCalc); syncCalc.setValue(true);/*from w w w.j a va 2s. c o m*/ buildControlPanelRow(resultTable, "", asyncCalc); startStopButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (calculationInProgress) { statusLabel.setText(statusLabel.getText() + "...Cancelled"); stopCalculation(); return; } htmlResults.setText(""); statusLabel.setText("Starting calculation"); calculationInProgress = true; startStopButton.setEnabled(false); startStopButton.setText("Working..."); startTime = System.currentTimeMillis(); final int numDigits = Integer .valueOf(numDigitsListBox.getValue(numDigitsListBox.getSelectedIndex())); if (syncCalc.getValue()) { /* * A DeferredCommand is used here so that the previous updates to the * user interface will appear. The synchronous computation will block * until the calculation is complete, freezing the user interface. */ DeferredCommand.addCommand(new Command() { public void execute() { doSyncCalculation(numDigits); } }); } else { doAsyncCalculation(numDigits); } } }); buildControlPanelRow(resultTable, "", startStopButton); tableWrapper.setWidget(resultTable); // Position the Animation so that it looks centered. Widget toy = new AnimationToy(); AbsolutePanel toyWrapper = new AbsolutePanel(); toyWrapper.setSize("450px", "210px"); toyWrapper.add(toy, 70, 0); outerPanel.add(toyWrapper); HTML desc = new HTML(INTERACTION_DESC); desc.setWidth("450px"); outerPanel.add(desc); outerPanel.add(tableWrapper); return outerPanel; }
From source file:com.google.gwt.gen2.demo.picker.client.SliderBarDemo.java
License:Apache License
/** * This is the entry point method.// ww w.jav a2 s . com */ public void onModuleLoad() { SliderBar.injectDefaultCss(); // 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.addValueChangeHandler(new ValueChangeHandler<Double>() { public void onValueChange(ValueChangeEvent<Double> event) { curBox.setText(event.getValue().toString()); } }); 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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 ClickHandler() { public void onClick(ClickEvent event) { 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); }
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.AbstractOption.java
License:Apache License
/** * Initialize the tab for the first time. *//* ww w . j av a 2 s .c o m*/ protected void initialize() { if (initialized) { return; } initialized = true; // Add the content wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); wrapper.add(new HTML(getDescription())); wrapper.add(onInitialize()); }
From source file:com.google.gwt.gen2.demo.scrolltable.client.PagingScrollTableDemo.java
License:Apache License
@Override protected AbstractScrollTable createScrollTable() { // Setup the controller tableModel = new DataSourceTableModel(); cachedTableModel = new CachedTableModel<Student>(tableModel); cachedTableModel.setPreCachedRowCount(50); cachedTableModel.setPostCachedRowCount(50); cachedTableModel.setRowCount(1000);/*w w w .ja v a 2 s. c o m*/ // Create a TableCellRenderer TableDefinition<Student> tableDef = createTableDefinition(); // Create the scroll table pagingScrollTable = new PagingScrollTable<Student>(cachedTableModel, tableDef); pagingScrollTable.setPageSize(50); pagingScrollTable.setEmptyTableWidget(new HTML("There is no data to display")); // Setup the bulk renderer FixedWidthGridBulkRenderer<Student> bulkRenderer = new FixedWidthGridBulkRenderer<Student>( pagingScrollTable.getDataTable(), pagingScrollTable); pagingScrollTable.setBulkRenderer(bulkRenderer); // Setup the formatting pagingScrollTable.setCellPadding(3); pagingScrollTable.setCellSpacing(0); pagingScrollTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH); return pagingScrollTable; }
From source file:com.google.gwt.gwtai.demo.client.CounterAppletTab.java
License:Apache License
private DialogBox createDialogBox(Object currentValue) { final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Current..."); VerticalPanel panelContent = new VerticalPanel(); panelContent.setWidth("100%"); panelContent.setSpacing(4);//from ww w . ja va 2 s. c o m dialogBox.setWidget(panelContent); HTML labelCurrentValue = new HTML("The current count is : " + currentValue); panelContent.add(labelCurrentValue); panelContent.setCellHorizontalAlignment(labelCurrentValue, VerticalPanel.ALIGN_CENTER); Button buttonCloseDlg = new Button("Close"); buttonCloseDlg.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); panelContent.add(buttonCloseDlg); panelContent.setCellHorizontalAlignment(buttonCloseDlg, VerticalPanel.ALIGN_RIGHT); return dialogBox; }
From source file:com.google.gwt.gwtai.demo.client.CounterAppletTab.java
License:Apache License
/** * Helper-Method to construct an HTML element containing some example code snippets. *//* w w w .ja v a 2 s . c om*/ private HTML createCodeHTML() { String html = "<b>CounterAppletTab.java</b>" + "<pre>...\n" + "VerticalPanel panelMain = new VerticalPanel();\n" + "Button buttonInc = new Button(\"Increment\");\n" + "final CounterApplet counterApplet = (CounterApplet) GWT.create(CounterApplet.class);\n\n" + "buttonInc.addClickListener(new ClickListener() {\n" + " public void onClick(Widget sender) {\n" + " counterApplet.increment();\n" + " }\n" + "});\n\n" + "Widget widgetApplet = AppletJSUtil.createAppletWidget(counterApplet);\n" + "panelMain.add(widgetApplet);\n\n" + "initWidget(panelMain);\n" + "...</pre>"; return new HTML(html); }
From source file:com.google.gwt.gwtai.demo.client.JavaFXDemo.java
License:Apache License
public void onModuleLoad() { DecoratedTabPanel tabPanel = new DecoratedTabPanel(); tabPanel.setWidth("800px"); tabPanel.getDeckPanel().setAnimationEnabled(true); VerticalPanel panelMain = new VerticalPanel(); panelMain.setWidth("100%"); panelMain.setSpacing(4);/*from w ww. j av a 2 s .co m*/ JavaFXApplet javaFxApplet = (JavaFXApplet) GWT.create(JavaFXApplet.class); Widget widgetApplet = AppletJSUtil.createAppletWidget(javaFxApplet); panelMain.add(new HTML( "This demo is featuring a " + "<a href=\"http://www.sun.com/software/javafx/\">JavaFX</a> applet " + "integrated into a <a href=\"http://code.google.com/webtoolkit/\">Goolge Web" + " Toolkit</a> application using the " + "<a href=\"http://code.google.com/p/gwtai/\">gwtai project</a>.")); panelMain.add(widgetApplet); panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER); DisclosurePanel panelCode = new DisclosurePanel("View code"); panelCode.setWidth("100%"); panelCode.setAnimationEnabled(true); panelCode.setContent(createCodeHTML()); panelMain.add(panelCode); tabPanel.add(panelMain, "JavaFXDemo"); tabPanel.selectTab(0); RootPanel.get().add(tabPanel); }
From source file:com.google.gwt.gwtai.demo.client.JavaFXDemo.java
License:Apache License
/** * Helper-Method to construct an HTML element containing some example code snippets. *//*w w w. j a va 2 s . c o m*/ private HTML createCodeHTML() { String html = "<b>CounterAppletTab.java</b>" + "<pre>...\n" + "VerticalPanel panelMain = new VerticalPanel();\n\n" + "JavaFXApplet javaFxApplet = (JavaFXApplet) GWT.create(JavaFXApplet.class);\n\n" + "Widget widgetApplet = AppletJSUtil.createAppletWidget(javaFxApplet);\n" + "panelMain.add(widgetApplet);\n" + "...</pre>" + "<hr>" + "<b>JavaFXApplet.java</b>" + "<pre>\n" + "@ImplementingClass(com.google.gwt.gwtai.demo.impl.JavaFXAppletStarter.class)\n" + "@Height(\"230px\")\n" + "@Width(\"320px\")\n" + "@Archive(\"GwtAI-Core.jar, JavaFXDemo.jar, javafxc.jar, javafxgui.jar, javafx-swing.jar, Scenario.jar, eula.jar\")\n" + "@Params(names={\"MainJavaFXScript\", \"draggable\"}, values={\"com.google.gwt.gwtai.demo.impl.JavaFXAppletImpl\", \"true\"})\n" + "public interface JavaFXApplet extends Applet { };\n" + "</pre>" + "<hr>" + "<b>JavaFXAppletStarter.java</b>" + "<pre>\n" + "public class JavaFXAppletStarter extends Applet implements JavaFXApplet {\n\n" + " public void init() {\n" + " // Omitted code to check the Java version\n" + " ...\n" + " super.init();\n" + " }\n" + "}" + "</pre>" + "<hr>" + "<b>JavaFXAppletImpl.fx</b>" + "<pre>\n" + "var o1:Number;\n\n" + "var t = Timeline {\n" + " repeatCount: Timeline.INDEFINITE\n" + " autoReverse: true\n" + " keyFrames: [\n" + " KeyFrame{\n" + " time : 0s\n" + " values: o1 => 0.3},\n" + " KeyFrame{\n" + " time : 3.5s\n" + " values: o1 => 1.0 tween Interpolator.EASEBOTH}\n" + " ]\n" + "}\n\n" + "t.play();\n\n" + "Stage {\n" + " title: \"GwtAI FX integration Demo\"\n" + " width: 320\n" + " height: 230\n" + " scene: Scene {\n" + " fill: Color.BLACK\n" + " content: [\n" + " Group {\n" + " content: [\n" + " Rectangle {\n" + " x: 20.0\n" + " y: 20.0\n" + " fill: Color.WHITESMOKE\n" + " width: 280\n" + " height: 80\n" + " arcHeight: 15\n" + " arcWidth: 15\n" + " stroke: Color.ORANGE\n" + " strokeWidth: 3\n" + " },\n" + " Text {\n" + " content: 'JavaFX rocks!'\n" + " font: Font {\n" + " name: 'Verdana',\n" + " embolden: true,\n" + " size: 30\n" + " }\n" + " fill: Color.ORANGE\n" + " x: 55.0\n" + " y: 75.0\n" + " }]\n" + " effect: Reflection {\n" + " fraction: 0.50\n" + " topOpacity: 0.8\n" + " }\n" + " opacity: bind o1\n" + " },\n" + " Text {\n" + " content: 'GWT and JavaFX => http://code.google.com/p/gwtai/'\n" + " font: Font {\n" + " name: 'Verdana',\n" + " size: 9\n" + " oblique: true\n" + " }\n" + " fill: Color.WHITESMOKE\n" + " x: 20.0\n" + " y: 175.0\n" + " }\n" + " ]\n" + " }\n" + "}" + "</pre>"; return new HTML(html); }
From source file:com.google.gwt.gwtai.demo.client.StopWatchAppletTab.java
License:Apache License
/** * Helper-Method to construct an HTML element containing some example code * snippets.//from w ww . ja va2 s . c o m */ private HTML createCodeHTML() { String html = "<b>StopWatchAppletTab.java</b>" + "<pre>...\n" + "StopWatchApplet stopWatchApplet = (StopWatchApplet) GWT.create(StopWatchApplet.class);\n" + "Widget widgetApplet = AppletJSUtil.createAppletWidget(stopWatchApplet);\n" + "AppletJSUtil.registerAppletCallback(stopWatchApplet, new StopWatchCallback(panelLaps));\n" + "...</pre>\n" + "<b>StopWatchCallback.java</b>" + "<pre>...\n" + "public class StopWatchCallback implements AppletCallback<String> {\n" + " private VerticalPanel _panelLaps;\n" + " private int _lap;\n\n" + " public StopWatchCallback(VerticalPanel panelLaps) {\n" + " _panelLaps = panelLaps;\n" + " _lap = 1;\n" + " }\n\n" + " public void callback(String msg) {\n" + " _panelLaps.add(new HTML(\"<b>Lap \" + _lap + \"</b> : \" + msg + \" seconds\"));\n" + " _lap++;\n" + " }\n" + "}</pre>" + "<b>StopWatchAppletImpl.java</b>" + "<pre>...\n" + "public class StopWatchAppletImpl extends JApplet implements StopWatchApplet {\n" + " ...\n" + " public void init() {\n" + " ...\n" + " JButton buttonLap = new JButton(\"Lap\");\n" + " buttonLap.addActionListener(new ActionListener() {\n\n" + " public void actionPerformed(ActionEvent e) {\n" + " startWatch();\n" + " AppletUtil.callback(StopWatchAppletImpl.this, _swLabel.getText());\n" + " }\n" + " });\n" + " ...\n" + " }\n" + "}</pre>"; return new HTML(html); }
From source file:com.google.gwt.gwtai.demo.client.StopWatchCallback.java
License:Apache License
public void callback(String msg) { _panelLaps.add(new HTML("<b>Lap " + _lap + "</b> : " + msg + " seconds")); _lap++;/*from ww w . j a v a 2 s . c om*/ }