Do you think IIT Guwahati certified course can help you in your career?
No
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.
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
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
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.