gpt4 book ai didi

Java SWT 在屏幕上集中绝对组合

转载 作者:行者123 更新时间:2023-12-01 08:52:14 25 4
gpt4 key购买 nike

我正在开发一个应用程序,我的雇主要求它具有绝对大小 (1024 x 768)。是否可以将此绝对组合插入到具有填充布局(或任何其他布局)的另一个组合中,并将绝对布局设置为始终居中?

我对开发屏幕相当陌生,所以我对这个概念感到困惑。

提前致谢。

最佳答案

您可以使用 GridLayout 将 Composite 在 Shell 中居中。

类似于:

Display display = new Display();

Shell shell = new Shell(display, SWT.SHELL_TRIM);

shell.setText("Stack Overflow");

shell.setFullScreen(true);

shell.setLayout(new GridLayout());

// Composite, just using a border here to show where it is
Composite composite = new Composite(shell, SWT.BORDER);

// Center composite in the shell using all available space
composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));

composite.setLayout(new GridLayout());

// Something to put in the composite
Label label = new Label(composite, SWT.BEGINNING);
label.setText("Text");

shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

display.dispose();

关于Java SWT 在屏幕上集中绝对组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42315195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com