Draw2d之FlowLayout布局
2011-04-11 21:05
183 查看
FlowLayout 以行的方式排列所有其管理之中的Figure;提供调整Figure的对齐方式和间距的方法。可对照AWT中的FlowLayout。
package com.jfans.layout;
import org.eclipse.draw2d.Cursors;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FlowLayout;
import org.eclipse.draw2d.GroupBoxBorder;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
//Draw2D之FlowLayout
public class FlowLayoutDemo {
protected Shell shell;
/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
try {
FlowLayoutDemo window = new FlowLayoutDemo();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window
*/
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
/**
* Create contents of the window
*/
protected void createContents() {
//Shell是Canvas的子类,而Canvas是Composite的子类
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
//创建LightweightSystem,放在shell上
LightweightSystem lws = new LightweightSystem(shell);
//创建应用程序中的最顶层图形
IFigure panel = new Figure();
//FlowLayout
FlowLayout flowLayout = new FlowLayout(true);//水平方向
flowLayout.setMinorSpacing(80);
flowLayout.setMajorAlignment(FlowLayout.ALIGN_LEFTTOP);
panel.setLayoutManager(flowLayout);
/*panel.setLayoutManager(new FlowLayout(false));*///垂直方向
//把这个图形放置于LightweightSystem的RootFigure里
lws.setContents(panel);
//创建应用程序中的其他图形,并放置于应用程序的顶层图形中
for(int i=0; i<10; i++){
Label label = new Label(String.valueOf(i));
panel.add(label);
}
}
}
package com.jfans.layout;
import org.eclipse.draw2d.Cursors;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FlowLayout;
import org.eclipse.draw2d.GroupBoxBorder;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
//Draw2D之FlowLayout
public class FlowLayoutDemo {
protected Shell shell;
/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
try {
FlowLayoutDemo window = new FlowLayoutDemo();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window
*/
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
/**
* Create contents of the window
*/
protected void createContents() {
//Shell是Canvas的子类,而Canvas是Composite的子类
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
//创建LightweightSystem,放在shell上
LightweightSystem lws = new LightweightSystem(shell);
//创建应用程序中的最顶层图形
IFigure panel = new Figure();
//FlowLayout
FlowLayout flowLayout = new FlowLayout(true);//水平方向
flowLayout.setMinorSpacing(80);
flowLayout.setMajorAlignment(FlowLayout.ALIGN_LEFTTOP);
panel.setLayoutManager(flowLayout);
/*panel.setLayoutManager(new FlowLayout(false));*///垂直方向
//把这个图形放置于LightweightSystem的RootFigure里
lws.setContents(panel);
//创建应用程序中的其他图形,并放置于应用程序的顶层图形中
for(int i=0; i<10; i++){
Label label = new Label(String.valueOf(i));
panel.add(label);
}
}
}
相关文章推荐
- Draw2d中的布局管理器Layout比较
- Draw2d中的布局管理器Layout比较
- UIView的layout(布局)与draw(绘图)
- Draw2D、GEF、GMF和EMF的解释
- 二十九、Java图形化界面设计——布局管理器之FlowLayout(流式布局)
- FlowLayout的布局组件的流向
- Android TagFlowLayout完全解析 一款针对Tag的布局
- 流式布局FlowLayout
- Draw2d 入门
- Draw2D 教程(五)
- 自定义流式布局FlowLayout
- Android应用程序窗口(Activity)的测量(Measure)、布局(Layout)和绘制(Draw)过程分析
- 流布局Flowlayout
- iOS流布局UICollectionView系列四——自定义FlowLayout进行瀑布流布局
- flowlayout流失布局:一行放不下直接换行
- [Web Chart系列之五] 3. 实战draw2d 之图形填充色(纯色 or 渐变)
- FlowLayout 流式布局加点击事件
- 利用布局FlowLayout修改设置里字符显示不全的问题
- FlowLayout,流式布局
- Draw2D简介