滚动条 显示 ScrollPaneExample

liuyacsdn 2013-04-23

滚动条 显示 ScrollPaneExample

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.GroupBoxBorder;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.ScrollPane;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class ScrollPaneExample {
	
	public static void main(String args[]) {
		Shell shell = new Shell();
		shell.setSize(300,200);
		shell.open();
		shell.setText("ScrollPaneExample");
		
		Figure fixedSize = new Figure();
//		fixedSize.setBorder(new LineBorder());
		fixedSize.setPreferredSize(400,400);

		ScrollPane scrollpane = new ScrollPane();
//		scrollpane.setBorder(new GroupBoxBorder("scrollpane"));
		scrollpane.setContents(fixedSize);


		LightweightSystem lws = new LightweightSystem(shell);
		lws.setContents(scrollpane);
		scrollpane.setSize(shell.getSize().x,shell.getSize().y);
		
		Display display = Display.getDefault();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}
}

相关推荐