Table of contents
1.
Introduction
2.
Class Declaration
3.
Nested Class Summary
4.
Class Constructors and Description
5.
Class Methods and Description
6.
GWT Vertical Panel Widget Methods Inherited
7.
GWT Vertical Panel Widget Example
8.
Frequently Asked Question
8.1.
What is GWT?
8.2.
What is GWT Vertical Panel Widget?
8.3.
What characteristics does GWT have?
8.4.
Who uses GWT - Google Web Toolkit?
8.5.
How advantageous is learning GWT?
9.
Conclusion
Last Updated: Mar 27, 2024

GWT Vertical Panel Widget

Author Alok Pandey
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

The VerticalPanel widget in GWT represents a panel that lays all of its widgets out in a single vertical row. This lays all of its widgets out in a single vertical column. This GWT Vertical Panel Widget can be used to create complex layouts with a single vertical row. Now let's see its class declaration along with other properties like class construction and methods.

A panel that lays all of its widgets out in a single vertical column.

A panel that lays all of its widgets out in a single vertical column.

Class Declaration

Declaration of com.google.gwt.user.client.ui.VerticalPanel class −

public class VerticalPanel
extends CellPanel
implements HasAlignment, InsertPanel.ForIsWidget

Nested Class Summary

GWT Vertical Panel Widget uses the different types of classes with specific purposes some of the nested classes are defined below

  • Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled

  • Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment

HasHorizontalAlignment.AutoHorizontalAlignmentConstant, HasHorizontalAlignment.HorizontalAlignmentConstant

  • Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasVerticalAlignment

HasVerticalAlignment.VerticalAlignmentConstant

  • Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.InsertPanel

InsertPanel.ForIsWidget

  • Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets

HasWidgets.ForIsWidget

Class Constructors and Description

GWT Vertical Panel Widget constructors and their descriptions are listed below

Constructor 

Description

VerticalPanel() It constructor for empty vertical Panel

Class Methods and Description

GWT Vertical Panel Widget methods and their descriptions are listed below

Sr.No.

Function name 

Description

1

void insert(Widget w, int beforeIndex)

This method Inserts a child widget before the specified index.

2

void set Horizontal Alignment (Has Horizontal Alignment.Horizontal Alignment Constant align)

It sets the default horizontal alignment to be used for widgets added to this panel.

3

Has Horizontal Alignment. Horizontal Alignment Constant get Horizontal Alignment()

 

This method is used to get the horizontal alignment

4

void add(Widget w)

This adds a child widget.

5

HasVerticalAlignment.VerticalAlignmentConstant getVerticalAlignment()

This method is used to get the vertical alignment.

6

void set Vertical Alignment (Has Vertical Alignment.Vertical Alignment Constant align)

It sets the default vertical alignment to be used for widgets added to this panel..

7

void insert(IsWidget w, int beforeIndex)

 

8

protected void onEnsureDebugId(java.lang.String baseID)

This method affect Elements: -# = the cell at the given index.

9

boolean remove(Widget w)

This removes a child widget.

GWT Vertical Panel Widget Methods Inherited

GWT vertical Panel Widget inherits the following methods

  • java.lang.Object
  • com.google.gwt.user.client.ui.UIObject
  • com.google.gwt.user.client.ui.Widget
  • com.google.gwt.user.client.ui.Panel
  • com.google.gwt.user.client.ui.ComplexPanel
  • com.google.gwt.user.client.ui.CellPanel
  • com.google.gwt.user.client.ui.VerticalPanel
     

GWT Vertical Panel Widget Example

In this example, we look for the usage of a vertical panel Widget in GWT in simple steps. Now let's have a look at the step-wise construction of the GWT Vertical Panel Widget.

Step 1: Create a project with the name VerticalpanelWidget under a package com.codingninjas.

 

Step 2: Change VerticalpanelWidget.gwt.xml, VerticalpanelWidget.css, VerticalpanelWidget.html and VerticalpanelWidget.java as explained below. 

 

Step 3: Compile and run the application to get the output

 

Content of the modified module descriptor src/com.codingninjas/VerticalpanelWidget.gwt.xml.

<?xml version = "1.0" encoding = "UTF-8"?>
<module rename-to = 'VerticalpanelWidget'>
	<inherits name = 'com.google.gwt.user.User'/>
	<inherits name = 'com.google.gwt.user.theme.clean.Clean'/>
	<entry-point class = 'com.codingninjas.client.VerticalpanelWidget'/>
	<source path = 'client'/>
	<source path = 'shared'/>
</module>

 

Content of the modified Style Sheet file war/VerticalpanelWidget.css.

body {
	text-align: center;
}

h1 {
	font-size: 32px;
	font-weight: bold;
	color: #f79d00;
	text-align: center;
}

.gwt-CheckBox {
	margin: 10px;
}

 

Content of the modified HTML host file war/VerticalpanelWidget.html.

<html>
	<head>
		<title>VerticalpanelWidget</title>
		<link rel="stylesheet" href="VerticalpanelWidget.css" />
		<script
			language="javascript"
			src="codingninjas/VerticalpanelWidget.nocache.js"
		></script>
	</head>

	<body>
		<h1>GWT Vertical Panel Widget Demonstration</h1>
		<div id="gwtContainer"></div>
	</body>
</html>

 

Let us have the following content of the Java file src/com.codingninjas/VerticalpanelWidget.java, which will demonstrate the use of the VerticalPanel widget.

package com.codingninjas.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.RootPanel;

public class VerticalpanelWidget implements EntryPoint {

    public void onModuleLoad() {
        VerticalPanel verticalPanel = new VerticalPanel();
        for (int i = 1; i <= 5; i++) {
            CheckBox checkBox = new CheckBox("Element" + i);
            verticalPanel.add(checkBox);
        }

        DecoratorPanel decoratorPanel = new DecoratorPanel();
        decoratorPanel.add(verticalPanel);

        /* Add the widgets to the root panel. */
        RootPanel.get().add(decoratorPanel);
    }
}
You can also try this code with Online Java Compiler
Run Code

 

Output:

Output Image

Frequently Asked Question

What is GWT?

GWT (Google web toolkit) is an open-source development toolkit provided by google for developing browser-based, complex Ajax applications. We can even develop Rich Internet Applications (RIA) in Java using GWT, which will then be compiled into Javascript and cross-browser compliant.

What is GWT Vertical Panel Widget?

The VerticalPanel widget represents a panel that lays all of its widgets out in a single vertical row.This lays all of its widgets out in a single vertical column. 

What characteristics does GWT have?

Asynchronous remote procedure calls, history management, bookmarking, UI abstraction, internationalization, and cross-browser portability.

Who uses GWT - Google Web Toolkit?

Companies like Crimsonlogic Pte. Ltd., StudyBlue Inc., and Intrado Inc. are using GWT.

How advantageous is learning GWT?

Many Google projects, both internal and external, are based on GWT, therefore, Google will need to sustain the technology as long as they need to keep improving the front-end.

Conclusion

In this article, we have extensively discussed how the project GWT Vertical Panel Widget. We have discussed its constructors, methods, and implementation. GWT Vertical Panel Widget is a part of form widgets that are used in many places while developing applications. and if you would like to learn more, check out our articles on

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. 

Enroll in our courses and refer to the mock test and problems available.

Take a look at the interview experiences and interview bundle for placement preparations.

Do upvote our blog to help other ninjas grow. 

Happy Coding!

Live masterclass