SlideShare a Scribd company logo
GWT Training – Session II Client-Side Implementation
Contents The User Interface Static widgets Form widgets Complex widgets Panels This are slides are based from the book “Google Web Toolkit Applications” by Ryan Desbury, 2008, Pearson Education
The User Interface GWT contains classes for building dynamic re-usable components (called widgets) based upon web browser's user interface features The user interface framework is similar to Java AWT/Swing For the purpose of this tutorial, we divide the different types of widgets into four categories – Static widgets, form widgets, complex widgets and panels
The User Interface Groups
Static Widgets They do not have any internal state or change dynamically on their own Can be part of a dynamic user interface in which the user interface code can change their properties and location at runtime, but not as a result of user actions Includes Label HTML Image Hyperlink
The Entry-Point Class Before we start building our user interface, we need to understand the Entry-Point Class Think of this class as the main class of your application with the java main() method that the JVM invokes first The Entry-Point class contains onModuleLoad() method which is the method that the GWT compiler calls first The class implements com.google.gwt.core.client.EntryPoint interface For the GWTTraining project, GWTTraining.java is the Entry-Point class (which is defined in the application's GWT configuration file)‏ import com.google.gwt.core.client. EntryPoint public class GWTTraining implements EntryPoint { public void onModuleLoad() { //your initial code goes here } }
Label A widget that contains arbitrary text, not interpreted as HTML. This widget uses a <div> element, causing it to be displayed with block layout Open the GWTTraining project in Eclipse Create a new Entry Point class called GWTTrainingWidget under File > New. We would use this entry class for our widgets tutorial. In the GWTTraining.gwt.xml configuration file, delete the entry-point definition for my.utm.kase.gettraining.client.GWTTraining. We only want to display the GWTTrainingWidgets entry-point when we run the applicaiton. Also edit the GWTTraining.html and delete the contents of the <body> tag so that we start from an empty page. Add the following import statements import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; Add the following code in the onModuleLoad() method Label label = new Label(&quot;Welcome to CASE, UTM&quot;); RootPanel.get().add(label); The code creates a new label widget and adds it to the root panel  A simple text “Welcome to CASE, UTM” is displayed when you run the application.
Label – Embellishing with CSS A great feature of GWT is letting you to achieve great presentations using CSS GWT widgets have default CSS names that let you set their style The label widget CSS is .gwt-Label { } Add the following to the /war/GWTTraining.css to change the appearance of the label widget: .gwt-Label{  background-color:silver;  color:green; text-align-center; border-style:groove; border-width:thick; border-color:navy; }
Label – Embellishing with CSS If you use the default GWT CSS names for the widgets, all widgets of the same class are affected. To demonstrate this, let's create another label widget by adding the following code in the GWTTrainingWidgets.java file: Label label2 = new Label(&quot;Where Advanced Learning Begins&quot;); RootPanel.get().add(label2); label2 also has the same appearance as the first label because it also inherits from .gwt-Label CSS name.
Label – Embellishing with CSS We can apply a different style for a particular label instead of the general class definition To demonstrate that add the following custom CSS definition in GWTTraining.css .label2 { background-color:orange; border-style:ridge; border-width:thick; border-color:navy; } Add the following code to set the style to label2 (before adding it to the root panel: label2.setStylePrimaryName(&quot;label2&quot;); When you refresh the browser you will see that label2 now has its own customized style. Styling with CSS is the same for all the other widgets in GWT. The default style names of the widgets can be found in the GWT API Java documentation. Info: CSS is a very powerful language that gives the web great look and feel. Because it is separated from the content (usually HTML), customizing the pages becomes very flexible. For further reading you may want to check: The Ultimate CSS reference
Customizing programatically Some properties of the Label (and other widgets as well) can be customized programatically
HTML Widget Used for rendering HTML Add the following codes to GWTTrainingWidgets.java RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line break RootPanel.get().add(new HTML(&quot;<b>CASE in bold</>&quot;)); //add bold text RootPanel.get().add(new HTML(&quot;<a href='http://www.case.utm.my'>Find  more about CASE</a>&quot;)); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line break Add import statement for com.google.gwt.user.client.ui.HTML Refresh the browser to  view the changes The HTML widget can be customized using CSS just like the Label widget. The default CSS name is .gwt-HTML
The Image Widget Accepts a URL pointing to an image file and renders it Create images folder: /war/gwttraining/images. Add case_logo.jpg to the folder which is provided in the training resources CD Add the following code: String url = GWT.getModuleBaseURL() + &quot;images/case_logo.jpg&quot;; Image image = new Image(url); RootPanel.get().add(image); CSS default style name is .gwt-Image
The Image Widget Add the following code to display image from an external server: RootPanel.get().add(new Image(&quot;http://www.case.utm.my/v2/images/intro_pic/case_intro_pic_1%20copy.gif&quot;)); The following output should be displayed when the browser is refreshed
The Form Widgets Widgets typically used with HTML forms Unlike traditional HTML forms, data is submitted to the server asynchrnously without refreshing the page GET form widgets can be used in ways similar to desktop applications and not necessarily inside a HTML form The widgets include: Button, CheckBox, RadioButton, ListBox, TextBox PasswordTextBox, TextArea, FileUpload, Hiddein ToggleButton, PushButton, SuggestBox and RichTextArea
The Button Widget Wraps the HTML form input with the type button (<input type=”button”>)‏ Can be used to invoke any action in the application To see the Button widget in action add the following code: Button alertButton = new Button(&quot;Alert&quot;);   //create the button alertButton.addClickHandler( new ClickHandler() { //handle event @Override public void onClick(ClickEvent event) { //handle button event here Window.alert(&quot;Alert button clicked!&quot;); } }); //add alertButton to root widget RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line  RootPanel.get().add(alertButton); //add button to root panel Just like other GWT widgets, the Button widget events are handled using the Observer pattern The observer (Event handler) observes the state of the subject (the user interface, e.g Button). When the subject’s state changes, the observer is notified. The default CSS name is .gwt-Button
ToggleButton and PushButton Widget Both similar to Button widget When  ToggleButton  is clicked it remains in a 'pressed state' until clicked again A PushButton supports customization of its look based on its state //toggle and push buttons ToggleButton toggleButton = new ToggleButton(&quot;Toggle me&quot;); PushButton pushButton = new PushButton(&quot;I'm a push button&quot;); pushButton.setSize(&quot;150&quot;, &quot;40&quot;); RootPanel.get().add(toggleButton); RootPanel.get().add(pushButton); You can set some widget properties “programmatically” without using CSS definition just as is done above in setting the size of the PushButton. However using CSS is the most recommended because it separates the presentation from the Java code which improves flexibility and maintainability.
Button Widgets with Images You may create buttons (Button, ToggleButton or PushButton) with images instead of text captions ToggleButton can be created with two images so that they can be represented in pressed and released states. ToggleButton imgToggleButton = new ToggleButton( new Image( GWT.getModuleBaseURL() +  &quot;images/h_toggle.jpg&quot;), new Image( GWT.getModuleBaseURL() +  &quot;images/v_toggle.jpg&quot;)‏ ); imgToggleButton.setSize(&quot;60&quot;, &quot;60&quot;); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line RootPanel.get().add(imgToggleButton);  //add imgToggleButton to  //root panel Copy the h_toggle.jpg and v_toggle.jpg to /war/gwttraining/images Released State Pressed State
Styling Button States with Css You can use CSS to generate different styles for ToggleButton and PushButton based on their states The default names for the states are shown in table below:
Checkbox Widget Wraps HTML’s check box input tag (<input type=”button”>)‏ Has two states - Checked/Unchecked You can programmatically set the state with the setChecked method by passing true for checked or false for unchecked Supports focus behavior and click events Default CSS name is .gwt-Checkbox
Checkbox Widget - Code Sample //checkbox widget final CheckBox checkBox = new CheckBox(&quot;Do u love GWT?&quot;); checkBox.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { //handle event if( checkBox.getValue() ) { Window.lert(&quot;Yeah, welcome to the world of GWT&quot;); } else { Window.alert(&quot;Sorry, u are missing a lot. U gotta think again&quot;); } } }); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(checkBox);
RadioButton Widget Usually belongs to a group of other RadioButtons so that only one selection can be made
RadioButton Widget – Sample Code //radio button widget final RadioButton redButton = new RadioButton(&quot;color&quot;, &quot;red&quot;); final RadioButton orangeButton = new RadioButton(&quot;color&quot;, &quot;orange&quot;); final RadioButton greenButton = new RadioButton(&quot;color&quot;, &quot;green&quot;); final Label label3 = new Label(&quot;&quot;); label3.setSize(&quot;25&quot;, &quot;25&quot;); label3.setStylePrimaryName(&quot;label3&quot;); ClickHandler radioButtonsHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { if( event.getSource() == redButton ) { label3.setStylePrimaryName(&quot;red&quot;); } else if( event.getSource() == orangeButton ) { label3.setStylePrimaryName(&quot;orange&quot;); } else { label3.setStylePrimaryName(&quot;green&quot;); } } };
RadioButton Widget – Sample Code (cont'd)‏ redButton.addClickHandler(radioButtonsHandler); orangeButton.addClickHandler(radioButtonsHandler); greenButton.addClickHandler(radioButtonsHandler); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line //add to root panel RootPanel.get().add(label3); RootPanel.get().add(redButton); RootPanel.get().add(orangeButton); RootPanel.get().add(greenButton); CSS Stlye .label3 { border-style:groove; width: 25px; height: 25px; } .red { background-color:red; } .orange { background-color:orange; } .green { background-color:green; }
ListBox Widget A group of options in a form of list in which only one option can be selected Two forms: Normal list Drop down list
ListBox Widget – Sample Code final ListBox colorList = new ListBox(); colorList.addItem(&quot;Red&quot;); colorList.addItem(&quot;Orange&quot;); colorList.addItem(&quot;Green&quot;); colorList.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if( colorList.getSelectedIndex() == 0 ) { label3.setStylePrimaryName(&quot;red&quot;); redButton.setValue(true); } else if( colorList.getSelectedIndex() == 1 ) { label3.setStylePrimaryName(&quot;orange&quot;); orangeButton.setValue(true); } else { label3.setStylePrimaryName(&quot;green&quot;); greenButton.setValue(true); } } }); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(colorList);
ListBox Sample Code – cont'd The previous code displays the drop down format of the ListBox Use the following code to change to the normal format: //change the list box format colorList.setVisibleItemCount(3);
SuggestBox Widget A text box with drop-down suggestions based on the word that you type Usually used when the list of items are too much to be displayed at a time E.g. Google Suggest Uses  SuggestOracle  instance to plug in dynamic results from datasource on the server MultiWordSuggestOracle can be used if the suggest list is generated at the client side
SuggestBox – Sample Code //SuggestBox String suggestString = &quot;The Faculty of Computer Science and Information &quot; + &quot;Systems, UTM  provides specialist teaching and conducts research &quot; + &quot;in fundamental and applied computer science, software &quot; + &quot;engineering, artificial intelligence and cognitive science. &quot; + &quot;We are proud to deliver outstanding undergraduate and &quot; + &quot;postgraduate education that offers varied and exciting &quot; + &quot;career opportunities around the world.&quot;; String words[] = suggestString.split(&quot; &quot;); MultiWordSuggestOracle suggestOracle = new MultiWordSuggestOracle(); suggestOracle.addAll(Arrays.asList(words)); SuggestBox suggestBox = new SuggestBox(suggestOracle); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(suggestBox); CSS Styles .gwt-SuggestBox {} .gwt-SuggestBoxPopup { border: 2px solid #C3D9FF; background-color:#E8EEF7; } .gwt-SuggestBoxPopup .item { } .gwt-SuggestBoxPopup .item-selected { background-color:#C3D9FF;}
TextBox Widget Encapsulates HTML’s input tag with type input (<input type=”input”>) Typically used for capturing small text input from user   //TextBox widget final TextBox emailBox = new TextBox(); emailBox.setText(&quot;<Enter your email>&quot;); emailBox.setStylePrimaryName(&quot;emailBox-blank&quot;); //add focus gain handler emailBox.addFocusHandler( new FocusHandler() { @Override public void onFocus(FocusEvent event) { String emailText = emailBox.getText(); if( emailText.equals(&quot;<Enter your email>&quot;)) { emailBox.setText(&quot;&quot;); } emailBox.removeStyleName(&quot;emailBox-blank&quot;); } });
TextBox Widget – cont'd //add focus lost handler emailBox.addFocusListener(new FocusListenerAdapter() { public void onLostFocus(Widget sender) { String emailText = emailBox.getText(); if( emailText.equals(&quot;&quot;)) { emailBox.setStylePrimaryName(&quot;emailBox-blank&quot;);  emailBox.setText(&quot;<Enter your email>&quot;); } } }); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(emailBox);
PasswordTextBox Widget Similar to TextBox but its contents are hidden to protect sensitive data   //PasswordTextBox widget PasswordTextBox passwordBox = new PasswordTextBox(); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add(passwordBox);
TextArea Widget Similar to TextBox but contents can span multiple pages   //TextArea widget TextArea textArea = new TextArea(); textArea.setCharacterWidth(80); textArea.setVisibleLines(10); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add( textArea );
FileUpload Widget Encapsulates HTML’s input tag with its type attribute set to file (<input type='file'>)‏ Allows users to select a file from their local file system, usually to be uploaded to the server //FileUpload widget FileUpload fileUpload = new FileUpload(); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add( fileUpload );
Hidden Widget Encapsulates HTML’s input tag of type hidden (<input type='hidden'>)‏ It is used with the FormPanel to submit a form asynchronously to the server.
Complex Widgets User interface widgets in web pages that do not have HTML tag equivalents.  They are created by compositing HTML tags together and handling user events through JavaScript to emulate more sophisticated widgets.  GWT has some complex widgets in its library Advanced custom widgets can also be built with GWT
Tree Widget Displays a hierarchical view of data that can be expanded and collapsed similar to tree widgets in desktop applications typically You can add simple text or widgets as children of the tree The TreeItem widget can be used to achieve several levels of hierarchy
TreeWidget – Sample Code //Tree Widget Tree rootTree = new Tree(); TreeItem treeItem1 = new TreeItem(&quot;Contact 1&quot;); treeItem1.addItem(new Image(GWT.getModuleBaseURL() + &quot;images/contact.jpg&quot;)); treeItem1.addItem(new Image(GWT.getModuleBaseURL() + &quot;images/mail.jpeg&quot;)); TreeItem treeItem2 = new TreeItem(&quot;Contact 2&quot;); treeItem2.addItem(new Image(&quot;images/contact.jpg&quot;)); treeItem2.addItem(new Image(&quot;images/mail.jpeg&quot;)); rootTree.addItem(treeItem1); rootTree.addItem(treeItem2); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add( rootTree ); CSS Style Rules .gwt-Tree {} .gwt-Tree .gwt-TreeItem {} .gwt-Tree .gwt-TreeItem-selected {}
MenuBar Widget Similar to menu bars on desktop applications Displays list of menus to be selected //MenuBar widget MenuBar lecturerMenu = new MenuBar(true); //orient vertically lecturerMenu.addItem(&quot;Save Records&quot; , new Command() { public void execute() { Window.alert(&quot;Saved&quot;); } }); MenuBar studentMenu = new MenuBar(true); //orient vertically studentMenu.addItem(&quot;Register&quot; , new Command() { public void execute() { //add register event } });
MenuBar Widget – cont'd studentMenu.addItem(&quot;View Records&quot; , new Command() { public void execute() { //view records event } }); MenuBar menu = new MenuBar(); menu.addItem(&quot;Lecturer&quot;, lecturerMenu); menu.addItem(&quot;Student&quot;, studentMenu); RootPanel.get().add(menu, 0, 0);
MenuBar Widget – CSS Styles .gwt-MenuBar { background-color:#F3F5F6; border: 1px; } .gwt-MenuBar .gwt-MenuItem { font-size: 9pt; cursor:hand; cursor:pointer; padding:2px 5px 2px 5px; margin:0px; } .gwt-MenuBar .gwt-MenuItem-selected { background-color:#316AC5; color:white; }
Simple Layout Panels Panels are used to organize the layout of the various widgets we have covered so far. GWT has several layout widgets that provide this functionality The simple Layout Panels include: FlowPanel VerticalPanel HorizontalPanel
FlowPanel It functions like the HTML layout Child widgets of the FlowPanel are displayed horizontally and then wrapped to the next row down when there is not enough horizontal room left //FlowPanel FlowPanel flowPanel = new FlowPanel(); for( int i = 1; i <= 20; i++ ) { flowPanel.add(new Button(&quot;Button &quot; + String.valueOf(i))); } RootPanel.get().add(flowPanel);
FlowPanel – cont'd If you run the code and resize the browser window smaller, you will see that the child widgets (buttons) are displaced to the next row when the space becomes insufficient to display in one row The result is opposite if you resize the window bigger
HorizontalPanel and VerticalPanel HorizontalPanel is similar to FlowPanel but uses scrollbar to display its widgets if there is no enough room instead of displacing to the next row VerticalPanel organizes its child widgets in a vertical orientation
HorizontalSplitPanel and VerticalSplitPanel They are divided into two panels that be resized
FlexTable and Grid Widgets Encapsulates HTML's table tag (<table />)‏ They display child widgets in a grid spanning vertically and horizontally.  The Grid widget enforces an explicitly set number of rows and cells for each row.  The FlexTable is more flexible, allowing cells to be added as needed, rows to have a variable number of cells, and cells to span multiple rows or columns
FlexTable and Grid Widgets – cont'd //Grid Grid grid = new Grid(3,3); for( int i = 0; i < 3; i++) { for( int j = 0; j < 3; j++ ) { grid.setWidget(i,j,new Image(GWT.getModuleBaseURL() +  &quot;images/tree2.jpg&quot;)); } } //FlexTable FlexTable flexTable = new FlexTable(); flexTable.setWidget(0,0, new HTML(&quot;Flex Table Widget&quot;)); flexTable.getFlexCellFormatter().setColSpan(0, 0, 4); for( int i = 0; i < 4; i++ ) { flexTable.setWidget(1, i, new Image(GWT.getModuleBaseURL() +  &quot;images/tree.jpeg&quot;)); }
FlexTable and Grid Widgets – cont'd flexTable.setWidget(2,0, new Image(GWT.getModuleBaseURL() +  &quot;images/tree2.jpg&quot;));  flexTable.setWidget(2,1, new Image(GWT.getModuleBaseURL() +  &quot;images/tree2.jpg&quot;));  flexTable.getFlexCellFormatter().setColSpan(2, 0, 2);  flexTable.getFlexCellFormatter().setColSpan(2, 1, 2);  flexTable.setWidget(3, 0, new Image(GWT.getModuleBaseURL() +  &quot;images/tree_big.png&quot;)); flexTable.getFlexCellFormatter().setColSpan(3, 0, 4);  HorizontalSplitPanel hSplitPanel = new HorizontalSplitPanel(); hSplitPanel.setLeftWidget(flexTable); hSplitPanel.setRightWidget(grid); RootPanel.get().add(hSplitPanel);
Customizing the Widgets HorizontalSplitPanel hSplitPanel = new HorizontalSplitPanel(); hSplitPanel.setLeftWidget(flexTable); hSplitPanel.setRightWidget(grid); RootPanel.get().add(hSplitPanel); //vertical panel 2 VerticalPanel vPanel2 = new VerticalPanel(); vPanel2.add(rootTree); vPanel2.add(flowPanel); RootPanel.get().add(vPanel2);
Customizing the Widgets – cont'd //vertical panel 3 HorizontalPanel hPanel2 = new HorizontalPanel(); hPanel2.add(checkBox); hPanel2.add(label3); hPanel2.add(redButton); hPanel2.add(orangeButton); hPanel2.add(greenButton); hPanel2.add(colorList); VerticalPanel vPanel4 = new VerticalPanel(); vPanel4.add(textArea); vPanel4.add(fileUpload); RootPanel.get().add(vPanel4);
TabPanel Displays just one of its child widgets at a time and provides controls to select the child to display //TabPanel TabPanel tabPanel = new TabPanel(); tabPanel.add(vPanel2, &quot;Buttons&quot;); tabPanel.add(hPanel2, &quot;Options&quot;); tabPanel.add(vPanel4, &quot;Text&quot;); tabPanel.setSize(&quot;100%&quot;, &quot;100%&quot;); RootPanel.get().add(tabPanel);
Other Widgets DeckPanel DockPanel StackPanel HTMLPanel LazyPanel Composite SimplePanel ScrollPanel FocusPanel FormPanel DisclosurePanel PopupPanel DialogBox
This brings us to the end of the 2 nd  session of the GWT Training. In the next session we would learn how to establish communication between the client and server. Thank you

More Related Content

PPT
GWT Training - Session 3/3
PPT
GWT Training - Session 1/3
PDF
Angular JS2 Training Session #2
PDF
Guice tutorial
PDF
JSLab. Алексей Волков. "React на практике"
PDF
Angular 2 binding
PDF
Android how to hellowidget
ODP
GWT Training - Session 3/3
GWT Training - Session 1/3
Angular JS2 Training Session #2
Guice tutorial
JSLab. Алексей Волков. "React на практике"
Angular 2 binding
Android how to hellowidget

What's hot (20)

PPTX
Android data binding
ODP
Android training day 4
PDF
GWT integration with Vaadin
PDF
PDF
Flutter State Management Using GetX.pdf
DOCX
Adding a view
PDF
How to build crud application using vue js, graphql, and hasura
PDF
Introduction to Polymer and Firebase - Simon Gauvin
ODP
Android training day 5
PDF
Wave Workshop
PDF
Creating lightweight JS Apps w/ Web Components and lit-html
PDF
Introduction to Vue.js
PDF
Program imageviewer
TXT
Httpsitesgooglecomsitekaratasajtov
PPTX
Angular Workshop_Sarajevo2
PDF
What's new in Vaadin 8, how do you upgrade, and what's next?
PPTX
Introduction to Google Guice
PPTX
AngularJS
PDF
Capstone ms2
PDF
Anton Minashkin Dagger 2 light
Android data binding
Android training day 4
GWT integration with Vaadin
Flutter State Management Using GetX.pdf
Adding a view
How to build crud application using vue js, graphql, and hasura
Introduction to Polymer and Firebase - Simon Gauvin
Android training day 5
Wave Workshop
Creating lightweight JS Apps w/ Web Components and lit-html
Introduction to Vue.js
Program imageviewer
Httpsitesgooglecomsitekaratasajtov
Angular Workshop_Sarajevo2
What's new in Vaadin 8, how do you upgrade, and what's next?
Introduction to Google Guice
AngularJS
Capstone ms2
Anton Minashkin Dagger 2 light
Ad

Similar to GWT Training - Session 2/3 (20)

PDF
GWT training session 2
PPT
Google Web Toolkits
DOC
Hats tutorial custom widget
PDF
Introducing GWT Polymer (vaadin)
PPTX
SoftShake 2013 - Vaadin componentization
PPT
Wicket Introduction
PPTX
What's new in ASP.NET 4
PPT
Mashups as Collection of Widgets
ODP
Qt Workshop
PDF
Statefull Widget.pdf
PPT
PPT
Gooogle Web Toolkit
ODP
ActiveWeb: Chicago Java User Group Presentation
PPT
Basic of Abstract Window Toolkit(AWT) in Java
PDF
Developer Student Clubs NUK - Flutter for Beginners
PPTX
Extend sdk
PDF
Gutenberg sous le capot, modules réutilisables
PDF
Value isnt changing and I cant seem to get the conversion to wor.pdf
PPT
introduction to JAVA awt programmin .ppt
PPT
Unit 1- awt(Abstract Window Toolkit) .ppt
GWT training session 2
Google Web Toolkits
Hats tutorial custom widget
Introducing GWT Polymer (vaadin)
SoftShake 2013 - Vaadin componentization
Wicket Introduction
What's new in ASP.NET 4
Mashups as Collection of Widgets
Qt Workshop
Statefull Widget.pdf
Gooogle Web Toolkit
ActiveWeb: Chicago Java User Group Presentation
Basic of Abstract Window Toolkit(AWT) in Java
Developer Student Clubs NUK - Flutter for Beginners
Extend sdk
Gutenberg sous le capot, modules réutilisables
Value isnt changing and I cant seem to get the conversion to wor.pdf
introduction to JAVA awt programmin .ppt
Unit 1- awt(Abstract Window Toolkit) .ppt
Ad

Recently uploaded (20)

PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
August Patch Tuesday
PDF
Getting Started with Data Integration: FME Form 101
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
STKI Israel Market Study 2025 version august
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
cloud_computing_Infrastucture_as_cloud_p
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Hindi spoken digit analysis for native and non-native speakers
A contest of sentiment analysis: k-nearest neighbor versus neural network
observCloud-Native Containerability and monitoring.pptx
Tartificialntelligence_presentation.pptx
Developing a website for English-speaking practice to English as a foreign la...
Web App vs Mobile App What Should You Build First.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Getting started with AI Agents and Multi-Agent Systems
August Patch Tuesday
Getting Started with Data Integration: FME Form 101
1 - Historical Antecedents, Social Consideration.pdf
STKI Israel Market Study 2025 version august
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
A comparative study of natural language inference in Swahili using monolingua...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
TLE Review Electricity (Electricity).pptx
Final SEM Unit 1 for mit wpu at pune .pptx
NewMind AI Weekly Chronicles – August ’25 Week III
cloud_computing_Infrastucture_as_cloud_p

GWT Training - Session 2/3

  • 1. GWT Training – Session II Client-Side Implementation
  • 2. Contents The User Interface Static widgets Form widgets Complex widgets Panels This are slides are based from the book “Google Web Toolkit Applications” by Ryan Desbury, 2008, Pearson Education
  • 3. The User Interface GWT contains classes for building dynamic re-usable components (called widgets) based upon web browser's user interface features The user interface framework is similar to Java AWT/Swing For the purpose of this tutorial, we divide the different types of widgets into four categories – Static widgets, form widgets, complex widgets and panels
  • 5. Static Widgets They do not have any internal state or change dynamically on their own Can be part of a dynamic user interface in which the user interface code can change their properties and location at runtime, but not as a result of user actions Includes Label HTML Image Hyperlink
  • 6. The Entry-Point Class Before we start building our user interface, we need to understand the Entry-Point Class Think of this class as the main class of your application with the java main() method that the JVM invokes first The Entry-Point class contains onModuleLoad() method which is the method that the GWT compiler calls first The class implements com.google.gwt.core.client.EntryPoint interface For the GWTTraining project, GWTTraining.java is the Entry-Point class (which is defined in the application's GWT configuration file)‏ import com.google.gwt.core.client. EntryPoint public class GWTTraining implements EntryPoint { public void onModuleLoad() { //your initial code goes here } }
  • 7. Label A widget that contains arbitrary text, not interpreted as HTML. This widget uses a <div> element, causing it to be displayed with block layout Open the GWTTraining project in Eclipse Create a new Entry Point class called GWTTrainingWidget under File > New. We would use this entry class for our widgets tutorial. In the GWTTraining.gwt.xml configuration file, delete the entry-point definition for my.utm.kase.gettraining.client.GWTTraining. We only want to display the GWTTrainingWidgets entry-point when we run the applicaiton. Also edit the GWTTraining.html and delete the contents of the <body> tag so that we start from an empty page. Add the following import statements import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; Add the following code in the onModuleLoad() method Label label = new Label(&quot;Welcome to CASE, UTM&quot;); RootPanel.get().add(label); The code creates a new label widget and adds it to the root panel A simple text “Welcome to CASE, UTM” is displayed when you run the application.
  • 8. Label – Embellishing with CSS A great feature of GWT is letting you to achieve great presentations using CSS GWT widgets have default CSS names that let you set their style The label widget CSS is .gwt-Label { } Add the following to the /war/GWTTraining.css to change the appearance of the label widget: .gwt-Label{ background-color:silver; color:green; text-align-center; border-style:groove; border-width:thick; border-color:navy; }
  • 9. Label – Embellishing with CSS If you use the default GWT CSS names for the widgets, all widgets of the same class are affected. To demonstrate this, let's create another label widget by adding the following code in the GWTTrainingWidgets.java file: Label label2 = new Label(&quot;Where Advanced Learning Begins&quot;); RootPanel.get().add(label2); label2 also has the same appearance as the first label because it also inherits from .gwt-Label CSS name.
  • 10. Label – Embellishing with CSS We can apply a different style for a particular label instead of the general class definition To demonstrate that add the following custom CSS definition in GWTTraining.css .label2 { background-color:orange; border-style:ridge; border-width:thick; border-color:navy; } Add the following code to set the style to label2 (before adding it to the root panel: label2.setStylePrimaryName(&quot;label2&quot;); When you refresh the browser you will see that label2 now has its own customized style. Styling with CSS is the same for all the other widgets in GWT. The default style names of the widgets can be found in the GWT API Java documentation. Info: CSS is a very powerful language that gives the web great look and feel. Because it is separated from the content (usually HTML), customizing the pages becomes very flexible. For further reading you may want to check: The Ultimate CSS reference
  • 11. Customizing programatically Some properties of the Label (and other widgets as well) can be customized programatically
  • 12. HTML Widget Used for rendering HTML Add the following codes to GWTTrainingWidgets.java RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line break RootPanel.get().add(new HTML(&quot;<b>CASE in bold</>&quot;)); //add bold text RootPanel.get().add(new HTML(&quot;<a href='http://www.case.utm.my'>Find more about CASE</a>&quot;)); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line break Add import statement for com.google.gwt.user.client.ui.HTML Refresh the browser to view the changes The HTML widget can be customized using CSS just like the Label widget. The default CSS name is .gwt-HTML
  • 13. The Image Widget Accepts a URL pointing to an image file and renders it Create images folder: /war/gwttraining/images. Add case_logo.jpg to the folder which is provided in the training resources CD Add the following code: String url = GWT.getModuleBaseURL() + &quot;images/case_logo.jpg&quot;; Image image = new Image(url); RootPanel.get().add(image); CSS default style name is .gwt-Image
  • 14. The Image Widget Add the following code to display image from an external server: RootPanel.get().add(new Image(&quot;http://www.case.utm.my/v2/images/intro_pic/case_intro_pic_1%20copy.gif&quot;)); The following output should be displayed when the browser is refreshed
  • 15. The Form Widgets Widgets typically used with HTML forms Unlike traditional HTML forms, data is submitted to the server asynchrnously without refreshing the page GET form widgets can be used in ways similar to desktop applications and not necessarily inside a HTML form The widgets include: Button, CheckBox, RadioButton, ListBox, TextBox PasswordTextBox, TextArea, FileUpload, Hiddein ToggleButton, PushButton, SuggestBox and RichTextArea
  • 16. The Button Widget Wraps the HTML form input with the type button (<input type=”button”>)‏ Can be used to invoke any action in the application To see the Button widget in action add the following code: Button alertButton = new Button(&quot;Alert&quot;); //create the button alertButton.addClickHandler( new ClickHandler() { //handle event @Override public void onClick(ClickEvent event) { //handle button event here Window.alert(&quot;Alert button clicked!&quot;); } }); //add alertButton to root widget RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line RootPanel.get().add(alertButton); //add button to root panel Just like other GWT widgets, the Button widget events are handled using the Observer pattern The observer (Event handler) observes the state of the subject (the user interface, e.g Button). When the subject’s state changes, the observer is notified. The default CSS name is .gwt-Button
  • 17. ToggleButton and PushButton Widget Both similar to Button widget When ToggleButton is clicked it remains in a 'pressed state' until clicked again A PushButton supports customization of its look based on its state //toggle and push buttons ToggleButton toggleButton = new ToggleButton(&quot;Toggle me&quot;); PushButton pushButton = new PushButton(&quot;I'm a push button&quot;); pushButton.setSize(&quot;150&quot;, &quot;40&quot;); RootPanel.get().add(toggleButton); RootPanel.get().add(pushButton); You can set some widget properties “programmatically” without using CSS definition just as is done above in setting the size of the PushButton. However using CSS is the most recommended because it separates the presentation from the Java code which improves flexibility and maintainability.
  • 18. Button Widgets with Images You may create buttons (Button, ToggleButton or PushButton) with images instead of text captions ToggleButton can be created with two images so that they can be represented in pressed and released states. ToggleButton imgToggleButton = new ToggleButton( new Image( GWT.getModuleBaseURL() + &quot;images/h_toggle.jpg&quot;), new Image( GWT.getModuleBaseURL() + &quot;images/v_toggle.jpg&quot;)‏ ); imgToggleButton.setSize(&quot;60&quot;, &quot;60&quot;); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal line RootPanel.get().add(imgToggleButton); //add imgToggleButton to //root panel Copy the h_toggle.jpg and v_toggle.jpg to /war/gwttraining/images Released State Pressed State
  • 19. Styling Button States with Css You can use CSS to generate different styles for ToggleButton and PushButton based on their states The default names for the states are shown in table below:
  • 20. Checkbox Widget Wraps HTML’s check box input tag (<input type=”button”>)‏ Has two states - Checked/Unchecked You can programmatically set the state with the setChecked method by passing true for checked or false for unchecked Supports focus behavior and click events Default CSS name is .gwt-Checkbox
  • 21. Checkbox Widget - Code Sample //checkbox widget final CheckBox checkBox = new CheckBox(&quot;Do u love GWT?&quot;); checkBox.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { //handle event if( checkBox.getValue() ) { Window.lert(&quot;Yeah, welcome to the world of GWT&quot;); } else { Window.alert(&quot;Sorry, u are missing a lot. U gotta think again&quot;); } } }); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(checkBox);
  • 22. RadioButton Widget Usually belongs to a group of other RadioButtons so that only one selection can be made
  • 23. RadioButton Widget – Sample Code //radio button widget final RadioButton redButton = new RadioButton(&quot;color&quot;, &quot;red&quot;); final RadioButton orangeButton = new RadioButton(&quot;color&quot;, &quot;orange&quot;); final RadioButton greenButton = new RadioButton(&quot;color&quot;, &quot;green&quot;); final Label label3 = new Label(&quot;&quot;); label3.setSize(&quot;25&quot;, &quot;25&quot;); label3.setStylePrimaryName(&quot;label3&quot;); ClickHandler radioButtonsHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { if( event.getSource() == redButton ) { label3.setStylePrimaryName(&quot;red&quot;); } else if( event.getSource() == orangeButton ) { label3.setStylePrimaryName(&quot;orange&quot;); } else { label3.setStylePrimaryName(&quot;green&quot;); } } };
  • 24. RadioButton Widget – Sample Code (cont'd)‏ redButton.addClickHandler(radioButtonsHandler); orangeButton.addClickHandler(radioButtonsHandler); greenButton.addClickHandler(radioButtonsHandler); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line //add to root panel RootPanel.get().add(label3); RootPanel.get().add(redButton); RootPanel.get().add(orangeButton); RootPanel.get().add(greenButton); CSS Stlye .label3 { border-style:groove; width: 25px; height: 25px; } .red { background-color:red; } .orange { background-color:orange; } .green { background-color:green; }
  • 25. ListBox Widget A group of options in a form of list in which only one option can be selected Two forms: Normal list Drop down list
  • 26. ListBox Widget – Sample Code final ListBox colorList = new ListBox(); colorList.addItem(&quot;Red&quot;); colorList.addItem(&quot;Orange&quot;); colorList.addItem(&quot;Green&quot;); colorList.addChangeHandler( new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if( colorList.getSelectedIndex() == 0 ) { label3.setStylePrimaryName(&quot;red&quot;); redButton.setValue(true); } else if( colorList.getSelectedIndex() == 1 ) { label3.setStylePrimaryName(&quot;orange&quot;); orangeButton.setValue(true); } else { label3.setStylePrimaryName(&quot;green&quot;); greenButton.setValue(true); } } }); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(colorList);
  • 27. ListBox Sample Code – cont'd The previous code displays the drop down format of the ListBox Use the following code to change to the normal format: //change the list box format colorList.setVisibleItemCount(3);
  • 28. SuggestBox Widget A text box with drop-down suggestions based on the word that you type Usually used when the list of items are too much to be displayed at a time E.g. Google Suggest Uses SuggestOracle instance to plug in dynamic results from datasource on the server MultiWordSuggestOracle can be used if the suggest list is generated at the client side
  • 29. SuggestBox – Sample Code //SuggestBox String suggestString = &quot;The Faculty of Computer Science and Information &quot; + &quot;Systems, UTM provides specialist teaching and conducts research &quot; + &quot;in fundamental and applied computer science, software &quot; + &quot;engineering, artificial intelligence and cognitive science. &quot; + &quot;We are proud to deliver outstanding undergraduate and &quot; + &quot;postgraduate education that offers varied and exciting &quot; + &quot;career opportunities around the world.&quot;; String words[] = suggestString.split(&quot; &quot;); MultiWordSuggestOracle suggestOracle = new MultiWordSuggestOracle(); suggestOracle.addAll(Arrays.asList(words)); SuggestBox suggestBox = new SuggestBox(suggestOracle); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(suggestBox); CSS Styles .gwt-SuggestBox {} .gwt-SuggestBoxPopup { border: 2px solid #C3D9FF; background-color:#E8EEF7; } .gwt-SuggestBoxPopup .item { } .gwt-SuggestBoxPopup .item-selected { background-color:#C3D9FF;}
  • 30. TextBox Widget Encapsulates HTML’s input tag with type input (<input type=”input”>) Typically used for capturing small text input from user //TextBox widget final TextBox emailBox = new TextBox(); emailBox.setText(&quot;<Enter your email>&quot;); emailBox.setStylePrimaryName(&quot;emailBox-blank&quot;); //add focus gain handler emailBox.addFocusHandler( new FocusHandler() { @Override public void onFocus(FocusEvent event) { String emailText = emailBox.getText(); if( emailText.equals(&quot;<Enter your email>&quot;)) { emailBox.setText(&quot;&quot;); } emailBox.removeStyleName(&quot;emailBox-blank&quot;); } });
  • 31. TextBox Widget – cont'd //add focus lost handler emailBox.addFocusListener(new FocusListenerAdapter() { public void onLostFocus(Widget sender) { String emailText = emailBox.getText(); if( emailText.equals(&quot;&quot;)) { emailBox.setStylePrimaryName(&quot;emailBox-blank&quot;); emailBox.setText(&quot;<Enter your email>&quot;); } } }); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); //add a horizontal break line RootPanel.get().add(emailBox);
  • 32. PasswordTextBox Widget Similar to TextBox but its contents are hidden to protect sensitive data //PasswordTextBox widget PasswordTextBox passwordBox = new PasswordTextBox(); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add(passwordBox);
  • 33. TextArea Widget Similar to TextBox but contents can span multiple pages //TextArea widget TextArea textArea = new TextArea(); textArea.setCharacterWidth(80); textArea.setVisibleLines(10); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add( textArea );
  • 34. FileUpload Widget Encapsulates HTML’s input tag with its type attribute set to file (<input type='file'>)‏ Allows users to select a file from their local file system, usually to be uploaded to the server //FileUpload widget FileUpload fileUpload = new FileUpload(); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add( fileUpload );
  • 35. Hidden Widget Encapsulates HTML’s input tag of type hidden (<input type='hidden'>)‏ It is used with the FormPanel to submit a form asynchronously to the server.
  • 36. Complex Widgets User interface widgets in web pages that do not have HTML tag equivalents. They are created by compositing HTML tags together and handling user events through JavaScript to emulate more sophisticated widgets. GWT has some complex widgets in its library Advanced custom widgets can also be built with GWT
  • 37. Tree Widget Displays a hierarchical view of data that can be expanded and collapsed similar to tree widgets in desktop applications typically You can add simple text or widgets as children of the tree The TreeItem widget can be used to achieve several levels of hierarchy
  • 38. TreeWidget – Sample Code //Tree Widget Tree rootTree = new Tree(); TreeItem treeItem1 = new TreeItem(&quot;Contact 1&quot;); treeItem1.addItem(new Image(GWT.getModuleBaseURL() + &quot;images/contact.jpg&quot;)); treeItem1.addItem(new Image(GWT.getModuleBaseURL() + &quot;images/mail.jpeg&quot;)); TreeItem treeItem2 = new TreeItem(&quot;Contact 2&quot;); treeItem2.addItem(new Image(&quot;images/contact.jpg&quot;)); treeItem2.addItem(new Image(&quot;images/mail.jpeg&quot;)); rootTree.addItem(treeItem1); rootTree.addItem(treeItem2); RootPanel.get().add(new HTML(&quot;<hr/>&quot;)); RootPanel.get().add( rootTree ); CSS Style Rules .gwt-Tree {} .gwt-Tree .gwt-TreeItem {} .gwt-Tree .gwt-TreeItem-selected {}
  • 39. MenuBar Widget Similar to menu bars on desktop applications Displays list of menus to be selected //MenuBar widget MenuBar lecturerMenu = new MenuBar(true); //orient vertically lecturerMenu.addItem(&quot;Save Records&quot; , new Command() { public void execute() { Window.alert(&quot;Saved&quot;); } }); MenuBar studentMenu = new MenuBar(true); //orient vertically studentMenu.addItem(&quot;Register&quot; , new Command() { public void execute() { //add register event } });
  • 40. MenuBar Widget – cont'd studentMenu.addItem(&quot;View Records&quot; , new Command() { public void execute() { //view records event } }); MenuBar menu = new MenuBar(); menu.addItem(&quot;Lecturer&quot;, lecturerMenu); menu.addItem(&quot;Student&quot;, studentMenu); RootPanel.get().add(menu, 0, 0);
  • 41. MenuBar Widget – CSS Styles .gwt-MenuBar { background-color:#F3F5F6; border: 1px; } .gwt-MenuBar .gwt-MenuItem { font-size: 9pt; cursor:hand; cursor:pointer; padding:2px 5px 2px 5px; margin:0px; } .gwt-MenuBar .gwt-MenuItem-selected { background-color:#316AC5; color:white; }
  • 42. Simple Layout Panels Panels are used to organize the layout of the various widgets we have covered so far. GWT has several layout widgets that provide this functionality The simple Layout Panels include: FlowPanel VerticalPanel HorizontalPanel
  • 43. FlowPanel It functions like the HTML layout Child widgets of the FlowPanel are displayed horizontally and then wrapped to the next row down when there is not enough horizontal room left //FlowPanel FlowPanel flowPanel = new FlowPanel(); for( int i = 1; i <= 20; i++ ) { flowPanel.add(new Button(&quot;Button &quot; + String.valueOf(i))); } RootPanel.get().add(flowPanel);
  • 44. FlowPanel – cont'd If you run the code and resize the browser window smaller, you will see that the child widgets (buttons) are displaced to the next row when the space becomes insufficient to display in one row The result is opposite if you resize the window bigger
  • 45. HorizontalPanel and VerticalPanel HorizontalPanel is similar to FlowPanel but uses scrollbar to display its widgets if there is no enough room instead of displacing to the next row VerticalPanel organizes its child widgets in a vertical orientation
  • 46. HorizontalSplitPanel and VerticalSplitPanel They are divided into two panels that be resized
  • 47. FlexTable and Grid Widgets Encapsulates HTML's table tag (<table />)‏ They display child widgets in a grid spanning vertically and horizontally. The Grid widget enforces an explicitly set number of rows and cells for each row. The FlexTable is more flexible, allowing cells to be added as needed, rows to have a variable number of cells, and cells to span multiple rows or columns
  • 48. FlexTable and Grid Widgets – cont'd //Grid Grid grid = new Grid(3,3); for( int i = 0; i < 3; i++) { for( int j = 0; j < 3; j++ ) { grid.setWidget(i,j,new Image(GWT.getModuleBaseURL() + &quot;images/tree2.jpg&quot;)); } } //FlexTable FlexTable flexTable = new FlexTable(); flexTable.setWidget(0,0, new HTML(&quot;Flex Table Widget&quot;)); flexTable.getFlexCellFormatter().setColSpan(0, 0, 4); for( int i = 0; i < 4; i++ ) { flexTable.setWidget(1, i, new Image(GWT.getModuleBaseURL() + &quot;images/tree.jpeg&quot;)); }
  • 49. FlexTable and Grid Widgets – cont'd flexTable.setWidget(2,0, new Image(GWT.getModuleBaseURL() + &quot;images/tree2.jpg&quot;)); flexTable.setWidget(2,1, new Image(GWT.getModuleBaseURL() + &quot;images/tree2.jpg&quot;)); flexTable.getFlexCellFormatter().setColSpan(2, 0, 2); flexTable.getFlexCellFormatter().setColSpan(2, 1, 2); flexTable.setWidget(3, 0, new Image(GWT.getModuleBaseURL() + &quot;images/tree_big.png&quot;)); flexTable.getFlexCellFormatter().setColSpan(3, 0, 4); HorizontalSplitPanel hSplitPanel = new HorizontalSplitPanel(); hSplitPanel.setLeftWidget(flexTable); hSplitPanel.setRightWidget(grid); RootPanel.get().add(hSplitPanel);
  • 50. Customizing the Widgets HorizontalSplitPanel hSplitPanel = new HorizontalSplitPanel(); hSplitPanel.setLeftWidget(flexTable); hSplitPanel.setRightWidget(grid); RootPanel.get().add(hSplitPanel); //vertical panel 2 VerticalPanel vPanel2 = new VerticalPanel(); vPanel2.add(rootTree); vPanel2.add(flowPanel); RootPanel.get().add(vPanel2);
  • 51. Customizing the Widgets – cont'd //vertical panel 3 HorizontalPanel hPanel2 = new HorizontalPanel(); hPanel2.add(checkBox); hPanel2.add(label3); hPanel2.add(redButton); hPanel2.add(orangeButton); hPanel2.add(greenButton); hPanel2.add(colorList); VerticalPanel vPanel4 = new VerticalPanel(); vPanel4.add(textArea); vPanel4.add(fileUpload); RootPanel.get().add(vPanel4);
  • 52. TabPanel Displays just one of its child widgets at a time and provides controls to select the child to display //TabPanel TabPanel tabPanel = new TabPanel(); tabPanel.add(vPanel2, &quot;Buttons&quot;); tabPanel.add(hPanel2, &quot;Options&quot;); tabPanel.add(vPanel4, &quot;Text&quot;); tabPanel.setSize(&quot;100%&quot;, &quot;100%&quot;); RootPanel.get().add(tabPanel);
  • 53. Other Widgets DeckPanel DockPanel StackPanel HTMLPanel LazyPanel Composite SimplePanel ScrollPanel FocusPanel FormPanel DisclosurePanel PopupPanel DialogBox
  • 54. This brings us to the end of the 2 nd session of the GWT Training. In the next session we would learn how to establish communication between the client and server. Thank you