gpt4 book ai didi

java - 为什么调用 setMaximized 不起作用?

转载 作者:行者123 更新时间:2023-11-29 04:45:06 24 4
gpt4 key购买 nike

我创建了一个 JFace ApplicationWindow,我希望它最大化打开,但它不起作用,基本代码结构如下所示,我只是删除了创建 UI 和数据绑定(bind)的代码,在窗口上设置标题是有效的, 但窗口没有最大化,为什么?

public class XToolMain extends ApplicationWindow {
private final static FormToolkit formToolkit = new FormToolkit(Display.getDefault());

private String currentTx;

private Head headBean;

private Object bodyBean;

private DataBindingContext bindingContext ;

private SimpleDateFormat dateTime = new SimpleDateFormat("yyyyMMddHHmmss");

private SimpleDateFormat timestamp = new SimpleDateFormat("yyyyMMddHHmmssSSS");

private Config config;

private String app_id;

private String target;

private Text platformAdressText;

private ScrolledForm form;

private Text toOrgIdText;

private Text toOrgNameText;

private Text fromOrgIdText;

private Text fromOrgNameText;

private Text toTGOrgIdText;

private Button genButton;

/**
* Create the application window.
*/
public XToolMain() {
super(null);
setShellStyle(SWT.MIN | SWT.MAX | SWT.RESIZE);

config = new Config();

//-Datfsim.platformAddress=9.152.47.241 -Datfsim.toOrgId=313701099012 -Datfsim.toOrgName=贵州银行 -Datfsim.fromOrgId=cfcapolice1 -Datfsim.fromOrgName=测试公安机关
String c1 = System.getProperty("atfsim.platformAddress");
String c2 = System.getProperty("atfsim.toOrgId");
String c3 = System.getProperty("atfsim.toTGOrgId");
String c4 = System.getProperty("atfsim.toOrgName");
String c5 = System.getProperty("atfsim.fromOrgId");
String c6 = System.getProperty("atfsim.fromOrgName");

config.setPlatformAddress(c1);
config.setToOrgId(c2);
config.setToTGOrgId(c3);
config.setToOrgName(c4);
config.setFromOrgId(c5);
config.setFromOrgName(c6);
}

/**
* Create contents of the application window.
* @param parent
*/
@Override
protected Control createContents(Composite parent) {

// code to create UI

initDataBindings();

return container;
}




public static void main(String args[]) {
Realm.runWithDefault(SWTObservables.getRealm(Display.getCurrent()), new Runnable() {
public void run() {
try {
XToolMain window = new XToolMain();
window.setBlockOnOpen(true);
window.open();
formToolkit.dispose();
SWTResourceManager.dispose();
Display.getCurrent().dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);

newShell.setText("报文生成工具");
newShell.setMaximized(true);
}


protected void initDataBindings() {
// data binding code
}
}

最佳答案

setMaximized 放入 constrainShellSize 将起作用:

@Override
protected void constrainShellSize() {
super.constrainShellSize();
getShell().setMaximized(true);
}

归功于 https://vzurczak.wordpress.com/2013/08/18/maximizing-a-jface-dialog-programmatically/

关于java - 为什么调用 setMaximized 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37506691/

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