关键字: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); }