Draw2d 学习笔记五 布局管理器 ScrollPaneLayout ScrollPane

关键字:Draw2d ScrollPaneLayout  ScrollPane 布局管理器 滚动条

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

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

 

 


Draw2d 学习笔记五 布局管理器 ScrollPaneLayout ScrollPane_第1张图片
 

你可能感兴趣的:(Java,Draw2d)