Table of contents
1.
Introduction
2.
GWT SplitLayoutPanel
3.
GWT SplitLayoutPanel Class Declaration
4.
SplitLayoutPanel Nested Classes
5.
GWT SplitLayoutPanel Constructors
6.
SplitLayoutPanel Common Methods
7.
GWT SplitLayoutPanel Example
7.1.
Code
7.2.
Output
8.
Frequently Asked Questions
8.1.
What is GWT SplitLayoutPanel?
8.2.
How to get the splitter’s size in SplitLayoutPanel?
8.3.
What is the function of SplitLayoutPanel()?
8.4.
How to remove the child widget in SplitPanelLayout?
8.5.
What is the function of SplitLayoutPanel(int splitterSize)?
9.
Conclusion
Last Updated: Mar 27, 2024
Medium

GWT SplitLayoutPanel

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

While developing web applications we sometimes need to design a panel that arranges its child widgets in a "docked" pattern around the edges and leaves the middle empty for its final widget.

gwt splitlayoutpanel

In this article, we will discuss GWT SplitLayoutPanel which can be used to design a panel where the child widgets are "docked" along the corners and the last widget is given the leftover space in the middle.

GWT SplitLayoutPanel

SplitLayoutPanel is used to add user-positioned splitters between each of the panel’s child widgets. This panel is used in the same way as DockLayoutPanel, except that the sizes of its children are always given in Style. Unit.PX units and each pair of child widgets include a draggable splitter.

This widget will only operate in standards mode, which needs an explicit!DOCTYPE> declaration in the HTML page where it is used.

GWT SplitLayoutPanel Class Declaration

Let's look at the com.google.gwt.user.client.ui.SplitLayoutPanel definition.

public class SplitLayoutPanel extends DockLayoutPanel 
You can also try this code with Online Java Compiler
Run Code

SplitLayoutPanel Nested Classes

The nested classes of SplitLayoutPanel and their description are given below:

Sr. No. Constructor  Description
1. SplitLayoutPanel.HSplitter It divides the panel horizontally.
2. SplitLayoutPanel.Splitter It is the common splitter.
3. SplitLayoutPanel.VSplitter It divides the panel vertically.

GWT SplitLayoutPanel Constructors

Constructors that are provided by the SplitPanelLayout are given below:

Sr. No. Constructor  Description
1. SplitLayoutPanel() It creates a new SplitLayoutPanel with the standard splitter size of 8px.
2. SplitLayoutPanel(int splitterSize) It creates a new SplitLayoutPanel with the splitter size supplied in pixels.

SplitLayoutPanel Common Methods

Following are the methods that are provided by the SplitPanelLayout:

Sr. No. Method Description
1. getSplitterSize() It returns the splitter's size in pixels as an integer.
2. insert(Widge child, DockLayoutPanel.Direction 
direction, double size, Widget before)
The return type of this method is void. It adds a widget to the dock's chosen edge.
3. remove(Widget child) The return type of this method is boolean. It eliminates a child widget.
4.  setWidgetHidden(Widget widget, boolean hidden) It speicifies whether the specified widget should be hidden. The return value of this method is void.
5.  setWidgetMinSize(Widget child, int minSize) It specifies the smallest permitted size for the specified widget. The return value of this method is void.
6.  setWidgetSnapClosedSize(Widget child, int snapClosedSize) The return type of this method is void. It specifies the size below which the slider will collapse.
7.  setWidgetToggleDisplayAllowed(Widget child, boolean allowed) The return type of this method is void. It specifies whether or not double-clicking on the splitter toggles the widget's display.

GWT SplitLayoutPanel Example

Let's see an example of how to implement the SplitPanelLayout:

Code

First, create a file named SampleSplitLayoutPanel.java and paste the following code:

import com.google.gwt.event.logical.shared.ResizeEvent;  
import com.google.gwt.event.logical.shared.ResizeHandler;  
import com.google.gwt.user.client.Window;  
  
/*This is the entry point method. */  
  
 public void onModuleLoad() {   
  
// Create a two-pane layout with splitters.   
  
SplitLayoutPanel p = new SplitLayoutPanel();   
p.addWest(new HTML("Navigation Tree"), 128);   
  
// Attach the LayoutPanel to the RootLayoutPanel.   
  
RootLayoutPanel rp = RootLayoutPanel.get();   
rp.add(p);  
 }  
You can also try this code with Online Java Compiler
Run Code

 

Now create a CSS file and name it SampleSplitLayoutPanel.css and paste the following code:

body {  
   text-align: center;  
   font-family: verdana, sans-serif;  
}  
  
h1 {  
   font-size: 2em;  
   font-weight: bold;  
   color: #777777;  
   margin: 40px 0px 70px;  
   text-align: center;  
}  
.dockpanel td {  
   border: 1px solid #BBBBBB;  
   padding: 3px;  
} 

Output

gwt splitlayoutpanel

Frequently Asked Questions

What is GWT SplitLayoutPanel?

The GWT SplitLayoutPanel is identical to the GWT DockLayoutPanel in that the sizes of its children are always supplied in absolute value. Its child widget features a splitter between each widget, allowing the user to drag it accordingly.

How to get the splitter’s size in SplitLayoutPanel?

The getSplitterSize() method is used to get the splitter size in SplitLayoutPanel.

What is the function of SplitLayoutPanel()?

It creates a new SplitLayoutPanel with the standard splitter size of 8px.

How to remove the child widget in SplitPanelLayout?

We use the remove(Widget child) method to remove the child layout.

What is the function of SplitLayoutPanel(int splitterSize)?

SplitLayoutPanel(int splitterSize)  creates a new SplitLayoutPanel with the splitter size supplied in pixels.

Conclusion

In this article, we have extensively discussed the GWT SplitLayoutPanel. After giving a quick overview of the GWT SplitLayoutPanel, we spoke about how to put it into practice. Finally, a few frequently asked questions about the GWT SplitLayoutPanel.

Do you not feel eager to read/explore additional information on the subject of GWT after reading about the GWT SplitLayoutPanel? See the GWT ScrollPanel Widget, GWT RootLayoutPanel, and GWT TabPanel Widget learn more.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

thank you image

Live masterclass