Gwt-verticalpanel-widget

提供:Dev Guides
移動先:案内検索

GWT-VerticalPanelウィジェット

前書き

*VerticalPanel* ウィジェットは、すべてのウィジェットを単一の垂直行に配置するパネルを表します。

クラス宣言

以下は com.google.gwt.user.client.ui.VerticalPanel クラスの宣言です-

public class VerticalPanel
   extends CellPanel
      implements HasAlignment, InsertPanel.ForIsWidget

クラスコンストラクター

Sr.No. Constructor & Description
1

VerticalPanel()

空の垂直パネルのコンストラクター。

クラスメソッド

Sr.No. Function name & Description
1

void add(Widget w)

子ウィジェットを追加します。

2

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

水平方向の配置を取得します。

3

HasVerticalAlignment.VerticalAlignmentConstant getVerticalAlignment()

垂直方向の配置を取得します。

4 *void insert(IsWidget w, int beforeIndex) *
5
  • void insert(Widget w, int beforeIndex)*

指定されたインデックスの前に子ウィジェットを挿入します。

6

protected void onEnsureDebugId(java.lang.String baseID)

影響を受ける要素:-#=指定されたインデックスのセル。

7

boolean remove(Widget w)

子ウィジェットを削除します。

8

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

このパネルに追加されたウィジェットに使用されるデフォルトの水平方向の配置を設定します。

9

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

このパネルに追加されたウィジェットに使用されるデフォルトの垂直方向の配置を設定します。

継承されるメソッド

このクラスは、次のクラスからメソッドを継承します-

  • 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
  • java.lang.Object

VerticalPanelウィジェットの例

この例では、GWTのVerticalPanelウィジェットの使用方法を示す簡単な手順を紹介します。 次の手順に従って、_GWTで作成したGWTアプリケーションを更新します-アプリケーションの作成_の章-

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

以下は、変更されたモジュール記述子 src/com.finddevguides/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.finddevguides.client.HelloWorld'/>

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

</module>

以下は、変更されたスタイルシートファイル 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;
}

.gwt-CheckBox {
   margin: 10px;
}

以下は、変更されたHTMLホストファイル war/HelloWorldl の内容です。

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

   <body>
      <h1>VerticalPanel Widget Demonstration</h1>
      <div id = "gwtContainer"></div>
   </body>
</html>

VerticalPanelウィジェットの使用法を示すJavaファイル src/com.finddevguides/HelloWorld.java の内容を見てみましょう。

package com.finddevguides.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 HelloWorld implements EntryPoint {

   public void onModuleLoad() {
     //Create a vertical panel
      VerticalPanel verticalPanel = new VerticalPanel();

     //Add CheckBoxes to vertical Panel
      for(int i = 1;  i <= 10; i++){
         CheckBox checkBox = new CheckBox("Item" + i);
         verticalPanel.add(checkBox);
      }

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

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

すべての変更が完了したら、link:/gwt/gwt_create_application [GWT-アプリケーションの作成]の章で行ったように、アプリケーションをコンパイルして開発モードで実行します。 すべてがあなたのアプリケーションでうまくいけば、これは次の結果を生成します-

GWT VerticalPanelウィジェット