为什么在使用SWT_AWT网桥时,SWT Shell不会扩展?

时间:2011-06-01 16:42:27

标签: java applet swt awt

我在Applet中使用它。这是init函数的来源:

java.awt.Canvas awtParent;
setLayout(new java.awt.GridLayout(1, 1));
awtParent = new java.awt.Canvas();
add(awtParent);
display = new Display();
shell = org.eclipse.swt.awt.SWT_AWT.new_Shell(display, awtParent);
shell.setLayout(new org.eclipse.swt.layout.FillLayout());
String operatingSystem = System.getProperty("os.name").toLowerCase();
if (operatingSystem.equals("linux")) {
    GLData data = new GLData ();
    data.doubleBuffer = true;
    canvas = new GLCanvas(shell, SWT.NONE, data);
    ((GLCanvas)canvas).setCurrent();
} else {
    canvas = new Canvas(shell, SWT.EMBEDDED);
}
canvas.setLayout(new org.eclipse.swt.layout.FillLayout());
shell.open();
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
validate();
System.out.println(awtParent.getBounds());
System.out.println(shell.getBounds());
System.out.println(canvas.getBounds());

和结果:

java.awt.Rectangle[x=0,y=0,width=640,height=480]
Rectangle {0, 25, 1050, 656}
Rectangle {0, 0, 0, 0}

0 个答案:

没有答案