List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:com.josephalevin.gwtplug.example.barnyard.client.MainEntryPoint.java
License:Open Source License
@Override public void onModuleLoad() { final Label label = new Label("Welcome to the gwt-plug barnyard!"); RootPanel.get().add(label);/* www.j a va 2 s .c om*/ final Label speak = new Label("Click an below animal to see it speak:"); RootPanel.get().add(speak); PluginLoader<Animal> loader = PluginLoader.load(Animal.class); Iterator<Animal> animals = loader.iterator(); if (animals != null) { while (animals.hasNext()) { final Animal animal = animals.next(); Button button = new Button(animal.getName()); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { speak.setText(animal.speak()); } }); RootPanel.get().add(button); } } }
From source file:com.jythonui.client.dialog.util.StandardDialog.java
License:Apache License
static void dialog(IEventBus iBus, int a, String[] pars) { HTMLPanel ha = iBinder.create(M.getStandw()[a]); PaperDialog p = PolymerUtil.findPaperDialog(M.getBinders()[a], ha); Label header = (Label) PolymerUtil.findandverifyWidget(M.getBinders()[a], ha, "header", Label.class); String[] butt = null;//from ww w. j a v a 2s .c o m switch (a) { case OKDIALOG: butt = new String[] { "ok" }; break; case YESNODIALOG: butt = new String[] { "yes", "no" }; break; } for (String b : butt) { PaperButton ok = (PaperButton) PolymerUtil.findandverifyWidget(M.getBinders()[a], ha, b, PaperButton.class); ok.getPolymerElement().addEventListener("click", event -> { if (!CUtil.EmptyS(pars[2])) iBus.publish(new StandardDialogEvent(), new StandardDialogResult(pars[2], b.equals("yes"))); p.close(); }); } if (!CUtil.EmptyS(pars[1])) header.setText(pars[1]); Element e = ha.getElementById("content"); assert e != null; e.removeAllChildren(); HTML html = new HTML(pars[0]); e.insertFirst(html.getElement()); popupDraw(p, ha, null); }
From source file:com.mansi.client.board.InsertPanelExample.java
License:Apache License
public InsertPanelExample() { // addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE); int count = 0; // use the boundary panel as this composite's widget AbsolutePanel boundaryPanel = new AbsolutePanel(); boundaryPanel.setSize("100%", "100%"); setWidget(boundaryPanel);//from w w w.j a v a2 s . co m // initialize our column drag controller PickupDragController columnDragController = new PickupDragController(boundaryPanel, false); columnDragController.setBehaviorMultipleSelection(false); // initialize our widget drag controller PickupDragController widgetDragController = new PickupDragController(boundaryPanel, true); widgetDragController.setBehaviorMultipleSelection(false); // initialize horizontal panel to hold our columns HorizontalPanel horizontalPanel = new HorizontalPanel(); // horizontalPanel.setSize("100%", "100%"); horizontalPanel.setSpacing(SPACING); boundaryPanel.add(horizontalPanel); // initialize our column drop controller HorizontalPanelDropController columnDropController = new HorizontalPanelDropController(horizontalPanel); columnDragController.registerDropController(columnDropController); for (int col = 1; col <= COLUMNS; col++) { // initialize a vertical panel to hold the heading and a second vertical // panel VerticalPanel columnCompositePanel = new VerticalPanel(); // initialize inner vertical panel to hold individual widgets VerticalPanel verticalPanel = new VerticalPanelWithSpacer(); verticalPanel.setStyleName("compPanel"); verticalPanel.setSpacing(SPACING); horizontalPanel.add(columnCompositePanel); VerticalPanel widgetHolder = new VerticalPanel(); // initialize a widget drop controller for the current column VerticalPanelDropController widgetDropController = new VerticalPanelDropController(verticalPanel); widgetDragController.registerDropController(widgetDropController); final Label heading = new Label(); // Put together the column pieces final EditableLabel heading_temp = new EditableLabel(""); if (headings[col - 1] != null) { heading_temp.setText(headings[col - 1]); } else { heading_temp.setText("Column " + col); } final int column = col; EditableLabelListener listener = new EditableLabelListener() { @Override public void onLabelModified(String text, EditableLabel sender) { // TODO Auto-generated method stub heading.setText(""); heading_temp.setText(text); headings[column - 1] = heading_temp.getText(); System.out.println(headings[column - 1]); } }; heading_temp.addEditableLabelListener(listener); heading.addStyleName("heading"); heading.setSize("200px", "20px"); columnCompositePanel.add(heading_temp); columnCompositePanel.add(heading); widgetHolder.add(verticalPanel); widgetHolder.setSpacing(SPACING); widgetHolder.setStyleName("columns"); columnCompositePanel.setHeight("370px"); // columnCompositePanel.setSpacing(15); columnCompositePanel.add(widgetHolder); // make the column draggable by its heading columnDragController.makeDraggable(columnCompositePanel, heading); for (int row = 1; row <= ROWS; row++) { if (row < 5) { // initialize a widget HTML widget = new HTML("ID #" + ++count); widget.addStyleName("widget"); widget.setHeight("60px"); widget.setWidth("100px"); verticalPanel.add(widget); // make the widget draggable widgetDragController.makeDraggable(widget); } } } }
From source file:com.moesol.gwt.maps.client.Browser.java
License:Open Source License
public static FontSize getFontSize() { Label l = new Label(); l.setText("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"); Element e = l.getElement();//from w ww .j av a 2 s .c o m int width = e.getClientWidth() / 52; int height = e.getClientHeight(); return new FontSize(width, height); }
From source file:com.objetdirect.tatami.demo.client.GfxDemo.java
License:Open Source License
/** * shows a popup to scale a graphical Object **//*w ww.j av a 2s . co m*/ private void showPopupScaler(Widget sender) { if (current != null) { scaleFactor = 1; final PopupPanel popupScaler = new PopupPanel(true); popupScaler.addStyleName("GfxDemo-popup"); final Slider scaler = new Slider(Slider.HORIZONTAL, -10, 10, 1, true); scaler.setRuleMarkBottom(6, "3px"); HorizontalPanel scalePanel = new HorizontalPanel(); scalePanel.setSpacing(5); final Label labelScaler = new Label(); scalePanel.add(scaler); scalePanel.add(labelScaler); labelScaler.setText("x" + scaleFactor); ChangeListener scaleChange = new ChangeListener() { public void onChange(Widget sender) { int value = scaler.getValue(); if (current != null && value != 0) { if (value < 0) { final float minus = (scaler.getMinimum() - value) * (-1); float factor = (minus / (float) scaler.getMaximum()) / scaleFactor; if (current.getGroup() != null) { current.getGroup().scale(factor); } else { current.scale(factor); } scaleFactor = (minus / (float) scaler.getMaximum()); } else { float factor = (float) value / scaleFactor; if (current.getGroup() != null) { current.getGroup().scale(factor); } else { current.scale(factor); } scaleFactor = (float) value; } } labelScaler.setText("x" + scaleFactor); } }; scaler.addChangeListener(scaleChange); popupScaler.add(scalePanel); popupScaler.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop()); popupScaler.show(); } }
From source file:com.objetdirect.tatami.demo.client.GfxDemo.java
License:Open Source License
/** * Show a popup with a <code>Slider</code> to * perform some rotation of the current <code>GraphicObject</code> * *//*from www .ja v a 2 s . c o m*/ private void showPopupRotate(Widget sender) { if (current != null) { rotateDegree = 0; final PopupPanel popupRotate = new PopupPanel(true); popupRotate.addStyleName("GfxDemo-popup"); final Slider rotate = new Slider(Slider.HORIZONTAL, 0, 360, 0, true); HorizontalPanel rotatePanel = new HorizontalPanel(); rotatePanel.setSpacing(5); final Label label = new Label(); rotatePanel.add(rotate); rotatePanel.add(label); label.setText("" + rotateDegree); ChangeListener rotateChange = new ChangeListener() { public void onChange(Widget sender) { int value = rotate.getValue(); if (current != null && value != 0) { int degree = value - rotateDegree; if (current.getGroup() != null) { current.getGroup().rotate(degree); } else { current.rotate(degree); } rotateDegree = value; } label.setText(rotateDegree + ""); } }; rotate.addChangeListener(rotateChange); popupRotate.add(rotatePanel); popupRotate.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop()); popupRotate.show(); } }
From source file:com.oracle.wci.portlet168.client.WciJsr168StartUpPortlet.java
License:Apache License
/** * This is the entry point method./* ww w. j ava 2s . c o m*/ */ public void onModuleLoad() { final Button sendButton = new Button("Send ME"); final TextBox nameField = new TextBox(); nameField.setText("GWT User"); final Label errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending name to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendNameToServer(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendNameToServer(); } } /** * Send the name from the nameField to the server and wait for a response. */ private void sendNameToServer() { // First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); if (!FieldVerifier.isValidName(textToServer)) { errorLabel.setText("Please enter at least four characters"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); greetingService.greetServer(textToServer, new AsyncCallback<String>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
From source file:com.phideltcmu.recruiter.client.ui.table.SearchMatchTable.java
License:Creative Commons License
public SearchMatchTable(final Label statusLabel) { ButtonCell buttonCell = new ButtonCell() { @Override//from w w w . j a va 2 s . c o m public boolean handlesSelection() { return false; } }; Column<Person, String> addButtonColumn = new Column<Person, String>(buttonCell) { @Override public String getValue(Person person) { return person.getInTable() == true ? "Add Referral" : "Add to list"; } }; addButtonColumn.setFieldUpdater(new FieldUpdater<Person, String>() { @Override public void update(int i, Person person, String s) { statusLabel.setText("Adding " + person.getFullName() + "..."); DynamicRecruiter.RECRUIT_SERVICE.addPerson(person, DynamicRecruiter.authUser, new AddUserHandler(statusLabel)); } }); List<ExtraColumn> extraCols = new ArrayList<ExtraColumn>(); extraCols.add(new ExtraColumn("", addButtonColumn)); this.initColumns(extraCols); }
From source file:com.polymerui.client.view.panel.MainPanel.java
License:Apache License
@Override public void drawInfo(InfoType e, String s) { if (e == InfoType.TITLE) { Window.setTitle(s);/*w w w .ja va 2 s . c o m*/ return; } String pName = mapToElem.get(e); if (pName == null) { Utils.errAlertB(M.M().MainPanelNotImplemented(e.name())); return; } Widget w = PolymerUtil.findandverifyWidget(M.M().MainPanelActionName(e.name(), pName), ha, pName, Label.class); Label l = (Label) w; l.setText(s); }
From source file:com.preferanser.client.application.mvp.dialog.validation.ValidationDialogView.java
License:Open Source License
private void displayValidationError(String errorMessage) { Label errorLabel = GWT.create(Label.class); errorLabel.setText(errorMessage); listPanel.add(errorLabel);//w w w . j ava 2s .c o m }