/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.lwuit.layouts;
import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Form;
import com.sun.lwuit.geom.Dimension;
import java.util.*;
/**
* GroupLayout is a LayoutManager that hierarchically groups components to
* achieve common, and not so common, layouts. Grouping is done by instances
* of the Group class. GroupLayout supports two types of groups:
* <table>
* <tr><td valign=top>Sequential:<td>A sequential group positions its child
* elements sequentially, one after another.
* <tr><td valign=top>Parallel:<td>A parallel group positions its child
* elements in the same space on top of each other. Parallel groups
* can also align the child elements along their baseline.
* </table>
* Each Group can contain any number of child groups, Components or gaps.
* GroupLayout treats each axis independently. That is, there is a group
* representing the horizontal axis, and a separate group representing the
* vertical axis. The horizontal group is responsible for setting the x
* and width of its contents, where as the vertical group is responsible for
* setting the y and height of its contents.
* <p>
* The following code builds a simple layout consisting of two labels in
* one column, followed by two textfields in the next column:
* <pre>
* JComponent panel = ...;
* GroupLayout layout = new GroupLayout(panel);
* panel.setLayout(layout);
* layout.setAutocreateGaps(true);
* layout.setAutocreateContainerGaps(true);
* GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
* hGroup.add(layout.createParallelGroup().add(label1).add(label2)).
* add(layout.createParallelGroup().add(tf1).add(tf2));
* layout.setHorizontalGroup(hGroup);
* GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
* vGroup.add(layout.createParallelGroup(GroupLayout.BASELINE).add(label1).add(tf1)).
* add(layout.createParallelGroup(GroupLayout.BASELINE).add(label2).add(tf2));
* layout.setVerticalGroup(vGroup);
* </pre>
* <p>
* This layout consists of the following:
* <ul><li>The horizontal axis consists of a sequential group containing two
* parallel groups. The first parallel group consists of the labels,
* with the second parallel group consisting of the text fields.
* <li>The vertical axis similarly consists of a sequential group
* containing two parallel groups. The parallel groups align their
* contents along the baseline. The first parallel group consists
* of the first label and text field, and the second group consists
* of the second label and text field.
* </ul>
* There are a couple of things to notice in this code:
* <ul>
* <li>You need not explicitly add the components to the container, this
* is indirectly done by using one of the <code>add</code> methods.
* <li>The various <code>add</code> methods of <code>Groups</code> return
* themselves. This allows for easy chaining of invocations. For
* example, <code>group.add(label1).add(label2);</code> is equivalent to
* <code>group.add(label1);group.add(label2);</code>.
* <li>There are no public constructors for the Groups, instead
* use the create methods of <code>GroupLayout</code>.
* </ul>
* GroupLayout offer the ability to automatically insert the appropriate gap
* between components. This can be turned on using the
* <code>setAutocreateGaps()</code> method. Similarly you can use
* the <code>setAutocreateContainerGaps()</code> method to insert gaps
* between the components and the container.
*
* @version $Revision: 1.25 $
* @author Tomas Pavek
* @author Jan Stola
* @author Scott Violet
* @author Shai Almog
*/
public class GroupLayout extends Layout {
/**
* Compass-direction North (up).
*/
public static final int NORTH = 1;
/**
* Compass-direction east (right).
*/
public static final int EAST = 3;
/**
* Compass-direction south (down).
*/
public static final int SOUTH = 5;
/**
* Compass-direction west (left).
*/
public static final int WEST = 7;
// Used in size calculations
private static final int MIN_SIZE = 0;
private static final int PREF_SIZE = 1;
private static final int MAX_SIZE = 2;
// Used by prepare, indicates min, pref or max isn't going to be used.
private static final int SPECIFIC_SIZE = 3;
private static final int UNSET = Integer.MIN_VALUE;
/**
* Possible argument when linking sizes of components. Specifies the
* the two component should share the same size along the horizontal
* axis.
*
* @see #linkSize(Component[], int)
*/
public static final int HORIZONTAL = 1;
/**
* Possible argument when linking sizes of components. Specifies the
* the two component should share the same size along the vertical
* axis.
*
* @see #linkSize(Component[],int)
*/
public static final int VERTICAL = 2;
private static final int NO_ALIGNMENT = 0;
/**
* Possible alignment type. Indicates the elements should be
* aligned to the origin. For the horizontal axis with a left to
* right orientation this means aligned to the left.
*
* @see #createParallelGroup(int)
*/
public static final int LEADING = 1;
/**
* Possible alignment type. Indicates the elements should be
* aligned to the end. For the horizontal axis with a left to
* right orientation this means aligned to the right.
*
* @see #createParallelGroup(int)
*/
public static final int TRAILING = 2;
/**
* Possible alignment type. Indicates the elements should centered in
* the spaced provided.
*
* @see #createParallelGroup(int)
*/
public static final int CENTER = 4;
/**
* Possible alignment type. Indicates the elements should aligned along
* their baseline.
*
* @see #createParallelGroup(int)
*/
public static final int BASELINE = 3;
/**
* Possible value for the add methods that takes a Component.
* Indicates the size from the component should be used.
*/
public static final int DEFAULT_SIZE = -1;
/**
* Possible value for the add methods that takes a Component.
* Indicates the preferred size should be used.
*/
public static final int PREFERRED_SIZE = -2;
// Whether or not we automatically try and create the preferred
// padding between components.
private boolean autocreatePadding;
// Whether or not we automatically try and create the preferred
// padding between contai
没有合适的资源?快使用搜索试试~ 我知道了~
LWUIT 开发指南第一章里的 Hello World 源代码
共403个文件
class:296个
java:98个
jad:2个
需积分: 9 45 下载量 14 浏览量
2010-02-20
15:45:32
上传
评论
收藏 1.79MB ZIP 举报
温馨提示
博客《解读 LWUIT 之二:关于 LWUIT 开发指南中的 Hello World》中作者写的源代码。博客链接地址:http://blog.csdn.net/defonds/archive/2010/02/20/5313114.aspx。
资源推荐
资源详情
资源评论
收起资源包目录
LWUIT 开发指南第一章里的 Hello World 源代码 (403个子文件)
Form.class 40KB
Form.class 37KB
HTMLComponent.class 35KB
Component.class 34KB
DefaultLookAndFeel.class 32KB
List.class 32KB
Component.class 31KB
LWUITImplementation.class 30KB
HTMLComponent.class 30KB
LWUITImplementation.class 28KB
List.class 27KB
GameCanvasImplementation.class 27KB
Display.class 26KB
DefaultLookAndFeel.class 26KB
GameCanvasImplementation.class 25KB
TextField.class 24KB
Display.class 23KB
Resources.class 23KB
TextField.class 22KB
Resources.class 20KB
GroupLayout.class 20KB
Container.class 19KB
GroupLayout.class 18KB
Element.class 17KB
UIManager.class 17KB
TextArea.class 17KB
Transition3D.class 16KB
Container.class 16KB
Dialog.class 16KB
Element.class 16KB
Style.class 16KB
Dialog.class 15KB
UIManager.class 15KB
VirtualKeyboard.class 15KB
Transition3D.class 15KB
TextArea.class 15KB
Style.class 14KB
VirtualKeyboard.class 14KB
Border.class 14KB
Image.class 14KB
Form$MenuBar.class 13KB
Parser.class 13KB
GroupLayout$SequentialGroup.class 13KB
Image.class 12KB
CommonTransitions.class 12KB
Border.class 12KB
Form$MenuBar.class 12KB
LookAndFeel.class 11KB
TableLayout.class 11KB
Spinner.class 11KB
TabbedPane.class 11KB
LookAndFeel.class 11KB
Graphics.class 11KB
CommonTransitions.class 11KB
GroupLayout$SequentialGroup.class 11KB
TabbedPane.class 10KB
Parser.class 10KB
Graphics.class 10KB
Spinner.class 10KB
TableLayout.class 9KB
IndexedImage.class 9KB
HTMLForm.class 9KB
StaticAnimation.class 9KB
Calendar.class 8KB
Calendar.class 8KB
Table.class 8KB
Calendar$MonthView.class 8KB
IndexedImage.class 8KB
HTMLForm.class 8KB
Table.class 8KB
ComboBox.class 8KB
Label.class 8KB
EventDispatcher.class 8KB
Button.class 7KB
Calendar$MonthView.class 7KB
StaticAnimation.class 7KB
ComboBox.class 7KB
Label.class 7KB
Button.class 7KB
Log.class 7KB
Tree.class 7KB
SVGImplementation.class 7KB
Log.class 6KB
Tree.class 6KB
CustomFont.class 6KB
EventDispatcher.class 6KB
SVGImplementation.class 6KB
GroupLayout$AutopaddingSpring.class 6KB
BorderLayout.class 6KB
GroupLayout$ParallelGroup.class 6KB
HTMLFont.class 6KB
GroupLayout$AutopaddingSpring.class 6KB
GroupLayout$BaselineGroup.class 6KB
CustomFont.class 6KB
Font.class 6KB
Font.class 6KB
GroupLayout$ParallelGroup.class 6KB
SVGImage.class 5KB
BorderLayout.class 5KB
SVGImage.class 5KB
共 403 条
- 1
- 2
- 3
- 4
- 5
资源评论
Defonds
- 粉丝: 7093
- 资源: 420
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功