`

Draw2d 学习笔记四 XYLayout

 
阅读更多

XYLayout就是采用绝对坐标来确定子figure的位置和大小。

/**
 * Calculates and returns the preferred size of the input figure. Since in XYLayout the
 * location of the child should be preserved, the preferred size would be a region which
 * would hold all the children of the input figure. If no constraint is set, that child
 * is ignored for calculation. If width and height are not positive, the preferred
 * dimensions of the child are taken.

 */

所以用户至少要指定figure的位置,然后指定大小为负值,系统就会把用preferred size。

public class HelloWorld2 {
	public static void main(String args[]) {
		Shell shell = new Shell();
		shell.setText("Draw2d Hello World");
		shell.setSize(400, 400);
		shell.open();
		
		// create content 4 shell.
		createContent4Shell(shell);
		
		while (!shell.isDisposed ()) {
			if (!Display.getDefault().readAndDispatch ())
				Display.getDefault().sleep ();
		}
	}

	private static void createContent4Shell(Shell shell) {
		Panel rootFigure = new Panel();
		rootFigure.setLayoutManager(new XYLayout());
		for(int i=0; i<30; i++) {
			rootFigure.add(new Label("Label "+i) ,new Rectangle(15*i,15*i,-1,-1));
		}
		LightweightSystem lws = new LightweightSystem(shell);
		lws.setContents(rootFigure);
	}
}

 



 

 

  • 大小: 8.2 KB
分享到:
评论

相关推荐

    XYLayout

    宝蓝公司的j2se应用程序布局管理器,xy定位坐标,非常方便

    jbcl.jar XYLayout

    引入jbcl.jar就可以使用XYLayout了 省的自己写啦~~

    XYLayout工具包

    这是jbuilder以前自带的一个工具类,许多以前jbuilder写的东西需要这个做支撑,留给需要的人

    aframe-xylayout:像2D布局一样的Flexbox + A框架的UI组件

    xyLayout 类似于Flexbox的布局+ UI组件。 例子 现场演示: (多字节字符串支持) (日语输入支持) 用法 使用 (35kB) 在xylayout-all.min.js之后加载xylayout-all.min.js 。 需要支持ES2015的浏览器。 (适用...

    jbuilder.jar

    com.borland.jbcl.layout.* XYLayout jbuilder.jar

    包含 com.borland.jbcl.layout.jar +sun.net.jnin.jar+apsche

    包含众多很难找到的包 com.borland.jbcl.layout.jar sun公司的包 apache的一些类 isqlviewer包 javax.jms的包 artima

    hello.gef_GEFeclipse_gef_trainq78_these5nn_

    eclipse插件开发,利用gef框架,根据XYLayout布局,展示子页面

    欣欣记事本 V1.2.7

    添加Borland公司的com.borland.jbcl.layout.XYConstraints.class和com.borland.jbcl.layout.XYLayout.class两个类。 使得用户不需要再去下载这两个类了。 ----------------------- 版本:1.2.5: &gt;将修改字体的...

    欣欣记事本 V2.0.0

    添加Borland公司的com.borland.jbcl.layout.XYConstraints.class和com.borland.jbcl.layout.XYLayout.class两个类。 使得用户不需要再去下载这两个类了。 ----------------------- 版本:1.2.5: &gt;将修改字体的...

Global site tag (gtag.js) - Google Analytics