GWT - HorizantalSplitPanel Widget

Advertisements


Introduction

The HorizantalSplitPanel widget represents a panel that arranges two widgets in a single horizontal row and allows the user to interactively change the proportion of the width dedicated to each of the two widgets. Widgets contained within a HorizontalSplitPanel will be automatically decorated with scrollbars when necessary.

Class declaration

Following is the declaration for com.google.gwt.user.client.ui.HorizontalSplitPanel class:

@Deprecated
public final class HorizontalSplitPanel
   extends Panel

CSS style rules

Following default CSS Style rules will be applied to all the HorizontalSpiltPanel widget. You can override it as per your requirements.

.gwt-HorizontalSplitPanel { } 
.gwt-HorizontalSplitPanel hsplitter { } 

Class constructors

S.N.Constructor & Description
1HorizontalSplitPanel()
Deprecated.
2HorizontalSplitPanel(HorizontalSplitPanel.Resources resources)
Deprecated. Creates an empty horizontal split panel.
3HorizontalSplitPanel(HorizontalSplitPanel(HorizontalSplitPanelImages images))
Deprecated. replaced by HorizontalSplitPanel(Resources)

Class methods

S.N.Function name & Description
1void add(Widget w)
Deprecated. Adds a widget to a pane in the HorizontalSplitPanel.
2protected Element getElement(int index)
Deprecated. Gets the content element for the given index.
3Widget getEndOfLineWidget()
Deprecated. Gets the widget in the pane that is at the end of the line direction for the layout.
4Widget getLeftWidget()
Deprecated. Gets the widget in the left side of the panel.
5Widget getRightWidget()
Deprecated. Gets the widget in the right side of the panel.
6protected Element getSplitElement()
Deprecated. Gets the element that is acting as the splitter.
7Widget getStartOfLineWidget()
Deprecated. Gets the widget in the pane that is at the start of the line direction for the layout.
8protected Widget getWidget(int index)
Deprecated. Gets one of the contained widgets.
9boolean isResizing()
Deprecated. Indicates whether the split panel is being resized.
10java.util.Iterator<Widget> iterator()
Deprecated. Gets an iterator for the contained widgets.
11void onBrowserEvent(Event event)
Deprecated. Fired whenever a browser event is received.
12protected void onEnsureDebugId(java.lang.String baseID)
Deprecated. Affected Elements: -splitter = the container containing the splitter element. -right = the container on the right side of the splitter. -left = the container on the left side of the splitter.
13protected void onLoad()
Deprecated. This method is called immediately after a widget becomes attached to the browser's document.
14protected void onUnload()
Deprecated. This method is called immediately before a widget will be detached from the browser's document.
15boolean remove(Widget widget)
Deprecated. Removes a child widget.
16void setEndOfLineWidget(Widget w)
Deprecated. Sets the widget in the pane that is at the end of the line direction for the layout.
17void setLeftWidget(Widget w)
Deprecated. Sets the widget in the left side of the panel.
18void setRightWidget(Widget w)
Deprecated. Sets the widget in the right side of the panel.
19void setSplitPosition(java.lang.String pos)
Deprecated. Moves the position of the splitter.
20void setStartOfLineWidget(Widget w)
Deprecated. Sets the widget in the pane that is at the start of the line direction for the layout.
21protected void setWidget(int index, Widget w)
Deprecated. Sets one of the contained widgets.

Methods inherited

This class inherits methods from the following classes:

  • com.google.gwt.user.client.ui.UIObject

  • com.google.gwt.user.client.ui.Widget

  • com.google.gwt.user.client.ui.Panel

  • java.lang.Object

HorizontalSplitPanel Widget Example

This example will take you through simple steps to show usage of a HorizontalSplitPanel Widget in GWT. Follow the following steps to update the GWT application we created in GWT - Create Application chapter:

StepDescription
1Create a project with a name HelloWorld under a package com.tutorialspoint as explained in the GWT - Create Application chapter.
2Modify HelloWorld.gwt.xml, HelloWorld.css, HelloWorld.html and HelloWorld.java as explained below. Keep rest of the files unchanged.
3Compile and run the application to verify the result of the implemented logic.

Following is the content of the modified module descriptor src/com.tutorialspoint/HelloWorld.gwt.xml.

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='helloworld'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.                       -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>

  <!-- Specify the app entry point class.                         -->
  <entry-point class='com.tutorialspoint.client.HelloWorld'/>

  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>

</module>

Following is the content of the modified Style Sheet file war/HelloWorld.css.

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;
}

Following is the content of the modified HTML host file war/HelloWorld.html.

<html>
<head>
<title>Hello World</title>
   <link rel="stylesheet" href="HelloWorld.css"/>
   <script language="javascript" src="helloworld/helloworld.nocache.js">
   </script>
</head>
<body>

<h1>HorizontalSplitPanel Widget Demonstration</h1>
<div id="gwtContainer"></div>

</body>
</html>

Let us have following content of Java file src/com.tutorialspoint/HelloWorld.java which will demonstrate use of HorizontalSplitPanel widget.

package com.tutorialspoint.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.HTML;
import com.google.gwt.user.client.ui.HorizontalSplitPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class HelloWorld implements EntryPoint {

   public void onModuleLoad() {
      // Create a Horizontal Split Panel
      HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
      horizontalSplitPanel.setSize("300px", "200px");
      horizontalSplitPanel.setSplitPosition("30%");

      // Add some content
      String randomText = "This is a sample text.";
      for (int i = 0; i < 2; i++) {
         randomText += randomText;
      }
      horizontalSplitPanel.setRightWidget(new HTML(randomText));
      horizontalSplitPanel.setLeftWidget(new HTML(randomText));

      DecoratorPanel decoratorPanel = new DecoratorPanel();
      decoratorPanel.add(horizontalSplitPanel);
      // Add the widgets to the root panel.
      RootPanel.get().add(decoratorPanel);
   }
}

Once you are ready with all the changes done, let us compile and run the application in development mode as we did in GWT - Create Application chapter. If everything is fine with your application, this will produce following result:

GWT HorizontalSplitPanel Widget

Advertisements
Advertisements