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

本文介绍了一个使用 Draw2dScrollPaneLayout 的示例程序,通过创建 Shell 和 ScrollPane 对象,并添加带有标签的 Panel 控件,展示了如何实现滚动效果。此示例有助于理解 SWT 中 ScrollPane 的用法。
764

被折叠的 条评论
为什么被折叠?



