List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel
public HorizontalPanel()
From source file:com.google.gwt.gen2.demo.datepicker.client.DatePickerDemo.java
License:Apache License
private Widget dateRange() { VerticalPanel v = new VerticalPanel(); HorizontalPanel p = new HorizontalPanel(); v.add(p);// w w w . j a v a 2s . c o m start = new DateBox(); start.setAnimationEnabled(true); final DateBox end = new DateBox(); end.setAnimationEnabled(true); start.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent e) { if (e.isRightKeyCode() && start.getCursorPos() == start.getText().length()) { start.hideDatePicker(); end.setFocus(true); } } }); end.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent e) { if ((e.isLeftKeyCode()) && end.getCursorPos() == 0) { start.setFocus(true); end.hideDatePicker(); } } }); end.getDatePicker().addSelectionHandler(new SelectionHandler<Date>() { public void onSelection(SelectionEvent<Date> event) { start.removeStyleName("user-modified"); } }); start.showDate(new Date()); p.add(start); Label l = new Label(" - "); l.setStyleName("filler"); p.add(l); p.add(end); HorizontalPanel h2 = new HorizontalPanel(); v.add(h2); h2.add(new Button("Short format", new ClickListener() { public void onClick(Widget sender) { start.setDateFormat(DateTimeFormat.getShortDateFormat()); end.setDateFormat(DateTimeFormat.getShortDateFormat()); } })); h2.add(new Button("Long format", new ClickListener() { public void onClick(Widget sender) { start.setDateFormat(DateTimeFormat.getLongDateFormat()); end.setDateFormat(DateTimeFormat.getLongDateFormat()); } })); h2.add(new Button("clear", new ClickListener() { public void onClick(Widget sender) { start.clear(); end.clear(); } })); return v; }
From source file:com.google.gwt.gen2.demo.datepicker.client.DatePickerDemo.java
License:Apache License
private Widget eventPicker() { // Set up code final DatePicker picker = new DatePicker(); HorizontalPanel panel = new HorizontalPanel(); panel.add(picker);/* w w w. ja va 2s . c o m*/ VerticalPanel monitorEvents = new VerticalPanel(); panel.add(monitorEvents); monitorEvents .add(new HighlightHandlerCheckBox("Log highlight events", picker, new HighlightHandler<Date>() { public void onHighlight(HighlightEvent<Date> event) { Log.info("Highlight: " + event.getValue()); } })); monitorEvents.add(new SelectionHandlerCheckBox("Log select events", picker, new SelectionHandler<Date>() { public void onSelection(SelectionEvent<Date> event) { Log.info("Select: " + event.getOldValue() + "-->" + event.getNewValue()); } })); monitorEvents .add(new SelectionHandlerCheckBox("Disable selected item", picker, new SelectionHandler<Date>() { public void onSelection(SelectionEvent<Date> event) { Date d = event.getNewValue(); picker.setEnabledOnVisibleDate(d, !picker.isVisibleDateEnabled(d)); } })); return panel; }
From source file:com.google.gwt.gen2.demo.datepicker.client.DatePickerDemo.java
License:Apache License
private Widget stylingPicker() { final DatePicker picker = new DatePicker(); HorizontalPanel panel = new HorizontalPanel(); panel.add(picker);/* w w w .j ava 2s.c om*/ VerticalPanel styling = new VerticalPanel(); panel.add(styling); styling.add(new ShowRangeHandlerCheckBox("First and last displayed date will be underlined and bold", picker, new ShowRangeHandler<Date>() { public void onShowRange(ShowRangeEvent<Date> event) { Date startDate = event.getStart(); Date endDate = event.getEnd(); picker.addStyleToVisibleDate(startDate, "underlined-and-bold-text"); picker.addStyleToVisibleDate(endDate, "underlined-and-bold-text"); } })); styling.add( new ShowRangeHandlerCheckBox("5th of the month will be red", picker, new ShowRangeHandler<Date>() { public void onShowRange(ShowRangeEvent<Date> event) { Date monthShown = picker.getDateShown(); Date d = new Date(monthShown.getTime()); d.setDate(5); Log.info("Adding a red style to the 5th day of the month"); picker.addStyleToVisibleDate(d, "red-date"); } })); styling.add(new SelectionHandlerCheckBox("Add random style to selected date", picker, new SelectionHandler<Date>() { String[] styles = { "blue-background", "green-border", "red-text", "big-text", "green-background", "underlined-and-bold-text", "yellow-background" }; int styleIndex = 0; public void onSelection(SelectionEvent<Date> event) { if (event.getNewValue() != null) { styleIndex = ++styleIndex % styles.length; String styling = styles[styleIndex]; Log.info(event.getNewValue() + " has style " + styling, "styling"); picker.addGlobalStyleToDate(event.getNewValue(), styling); } } })); return panel; }
From source file:com.google.gwt.gen2.demo.simplewidget.client.SimpleWidgetDemo.java
License:Apache License
/** * This is the entry point method./* www.j av a 2 s . co m*/ */ public void onModuleLoad() { // Set up log handler. SimpleLogHandler handler = new SimpleLogHandler(); Log.addLogHandler(handler); HorizontalPanel p = new HorizontalPanel(); VerticalPanel v = new VerticalPanel(); p.add(v); p.add(handler); RootPanel.get().add(p); // Set up clickable widget. SimpleWidget clickable = new SimpleWidget("<h1>clickMe</h1>"); RootPanel.get().add(clickable); clickable.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { report("clicked on clickable"); } }); v.add(clickable); // Set up mouse move widget. SimpleWidget mouseMove = new SimpleWidget("<h2>mouseMove</h2>"); mouseMove.addMouseMoveHandler(new MouseMoveHandler() { public void onMouseMove(MouseMoveEvent event) { report("moved over mouseMove"); } }); v.add(mouseMove); // Set up mouse down and up handler, here some syntactic sugar would be nice // to have. SimpleWidget mouseDownAndUp = new SimpleWidget("<h3>mouse down and up events</h3>"); RootPanel.get().add(mouseDownAndUp); v.add(mouseDownAndUp); class MyHandler implements MouseDownHandler, MouseUpHandler { public void onMouseDown(MouseDownEvent event) { report("on mouse down"); } public void onMouseUp(MouseUpEvent event) { report("on mouse up"); } } MyHandler myHandler = new MyHandler(); mouseDownAndUp.addMouseDownHandler(myHandler); mouseDownAndUp.addMouseUpHandler(myHandler); v.add(mouseDownAndUp); }
From source file:com.google.gwt.gwtai.demo.client.CounterAppletTab.java
License:Apache License
public CounterAppletTab() { VerticalPanel panelMain = new VerticalPanel(); panelMain.setWidth("100%"); panelMain.setSpacing(4);//from ww w . j a va 2 s . c om Button buttonInc = new Button("Increment"); Button buttonDec = new Button("Decrement"); Button buttonGet = new Button("Get current count"); final CounterApplet counterApplet = (CounterApplet) GWT.create(CounterApplet.class); buttonInc.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { counterApplet.increment(); } }); buttonDec.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { counterApplet.decrement(); } }); buttonGet.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Object value = counterApplet.getCurrentValue(); DialogBox dialogBox = createDialogBox(value); dialogBox.center(); dialogBox.show(); } }); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(4); buttonPanel.add(buttonInc); buttonPanel.add(buttonDec); buttonPanel.add(buttonGet); Widget widgetApplet = AppletJSUtil.createAppletWidget(counterApplet); Label labelTitle = new Label( "To call a method on an applet object from within your GWT code - a piece of cake!"); DisclosurePanel panelCode = new DisclosurePanel("View code"); panelCode.setWidth("100%"); panelCode.setAnimationEnabled(true); panelCode.setContent(createCodeHTML()); panelMain.add(labelTitle); panelMain.add(widgetApplet); panelMain.add(buttonPanel); panelMain.add(panelCode); panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER); initWidget(panelMain); }
From source file:com.google.gwt.gwtai.demo.client.StopWatchAppletTab.java
License:Apache License
public StopWatchAppletTab() { VerticalPanel panelMain = new VerticalPanel(); panelMain.setWidth("100%"); panelMain.setSpacing(4);/*from w w w .j a v a 2 s.c om*/ VerticalPanel panelLaps = new VerticalPanel(); panelLaps.setWidth("100%"); panelLaps.setSpacing(4); Button buttonStart = new Button("Start"); Button buttonStop = new Button("Stop"); final StopWatchApplet stopWatchApplet = (StopWatchApplet) GWT.create(StopWatchApplet.class); buttonStart.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { stopWatchApplet.startWatch(); } }); buttonStop.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { stopWatchApplet.stopWatch(); } }); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(4); buttonPanel.add(buttonStart); buttonPanel.add(buttonStop); Widget widgetApplet = AppletJSUtil.createAppletWidget(stopWatchApplet); AppletJSUtil.registerAppletCallback(stopWatchApplet, new StopWatchCallback(panelLaps)); Label labelTitle = new Label( "Register a callback object to notify GWT of changes from within the Applet code."); DisclosurePanel panelCode = new DisclosurePanel("View code"); panelCode.setWidth("100%"); panelCode.setAnimationEnabled(true); panelCode.setContent(createCodeHTML()); panelMain.add(labelTitle); panelMain.add(widgetApplet); panelMain.add(buttonPanel); panelMain.add(panelLaps); panelMain.add(panelCode); panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(panelLaps, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(buttonPanel, VerticalPanel.ALIGN_CENTER); initWidget(panelMain); }
From source file:com.google.gwt.gwtai.demo.client.TrayIconAppletTab.java
License:Apache License
public TrayIconAppletTab() { VerticalPanel panelMain = new VerticalPanel(); panelMain.setWidth("100%"); panelMain.setSpacing(4);//from w w w . j av a 2 s . co m _trayIconApplet = (TrayIconApplet) GWT.create(TrayIconApplet.class); Widget widgetApplet = AppletJSUtil.createAppletWidget(_trayIconApplet); Label labelTitle = new Label( "Hook into the desktop tray from a GWT application. This is a 'Proof of Concept', the feature is not finished yet."); DisclosurePanel panelCode = new DisclosurePanel("View code"); panelCode.setWidth("100%"); panelCode.setAnimationEnabled(true); panelCode.setContent(createCodeHTML()); HorizontalPanel panelItems = new HorizontalPanel(); panelItems.setSpacing(4); final TextBox boxCaption = new TextBox(); final ListBox boxItemType = new ListBox(); boxItemType.addItem("Text"); boxItemType.addItem("CheckBox"); boxItemType.setSelectedIndex(0); Button buttonAdd = new Button("Add menu item"); buttonAdd.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { String caption = boxCaption.getText(); if (null == caption || caption.length() < 1) { Window.alert("Caption can not be empty"); } else { String itemType = boxItemType.getItemText(boxItemType.getSelectedIndex()); if (itemType.equals("CheckBox")) { _trayIconApplet.addCheckBoxItem(caption); } else { _trayIconApplet.addTextItem(caption); } } } }); Button buttonSeparator = new Button("Add separator"); buttonSeparator.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { _trayIconApplet.addSeparator(); } }); panelItems.add(boxCaption); panelItems.add(boxItemType); panelItems.add(buttonAdd); panelItems.add(buttonSeparator); panelMain.add(labelTitle); panelMain.add(widgetApplet); panelMain.add(panelItems); panelMain.add(panelCode); panelMain.setCellHorizontalAlignment(labelTitle, VerticalPanel.ALIGN_CENTER); panelMain.setCellHorizontalAlignment(widgetApplet, VerticalPanel.ALIGN_CENTER); initWidget(panelMain); }
From source file:com.google.gwt.inject.example.simple.client.SimpleWidget.java
License:Apache License
/** * Constructs a new simple widget.// w w w .ja v a2s .com * * @param messages a message interface providing message and error templates * @param service a service that returns fresh messages and errors * @param constants constants to label the buttons */ @Inject public SimpleWidget(SimpleMessages messages, SimpleService service, SimpleConstants constants, AsyncProvider<SimpleAsyncWidget> asyncWidgetProvider) { this.messages = messages; this.service = service; this.asyncWidgetProvider = asyncWidgetProvider; text = new Label(); text.addStyleName("message"); Button showMessage = new Button(constants.showMessage(), new ClickHandler() { public void onClick(ClickEvent event) { showMessage(); } }); Button showError = new Button(constants.showError(), new ClickHandler() { public void onClick(ClickEvent event) { showError(); } }); Button showAsync = new Button(constants.showMessageForAsync(), new ClickHandler() { public void onClick(ClickEvent event) { showAsync(); } }); HorizontalPanel buttons = new HorizontalPanel(); buttons.add(showMessage); buttons.add(showError); buttons.add(showAsync); VerticalPanel root = new VerticalPanel(); root.add(text); root.add(buttons); root.addStyleName("simple"); initWidget(root); }
From source file:com.google.gwt.language.sample.hellolanguage.client.LanguageDetectionDemo.java
License:Apache License
/** * Creates a demo panel./*w ww. j a va 2s .com*/ * * @return demo panel */ private VerticalPanel createDemoPanel() { VerticalPanel demoPanel = new VerticalPanel(); demoPanel.add(new Label("Enter text:")); demoPanel.add(inputTextArea); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setSpacing(10); hPanel.add(createLanguageDetectionButton()); hPanel.add(new Label(">>")); hPanel.add(outputDiv); demoPanel.add(hPanel); return demoPanel; }
From source file:com.google.gwt.language.sample.hellolanguage.client.TranslationDemo.java
License:Apache License
/** * Creates translation control panel containing list boxes for source and * destination languages, and a button to translate. * * @return panel containing controls//w ww . j a v a2 s .c o m */ private HorizontalPanel createTranslationControlPanel() { populateListBoxes(); HorizontalPanel listBoxesPanel = new HorizontalPanel(); listBoxesPanel.add(sourceLanguages); listBoxesPanel.add(new Label(">>")); listBoxesPanel.add(destinationLanguages); Button translateButton = createTranslateButton(); HorizontalPanel controlPanel = new HorizontalPanel(); controlPanel.setSpacing(10); controlPanel.setWidth("100%"); controlPanel.add(listBoxesPanel); controlPanel.add(translateButton); controlPanel.setCellHorizontalAlignment(translateButton, HasHorizontalAlignment.ALIGN_RIGHT); return controlPanel; }