为什么调用 setMaximized 不起作用?
why invoke setMaximized not work?
我创建了一个 JFace ApplicationWindow,我希望它最大化打开,但它不起作用,基本代码结构如下所示,我只是删除了创建 UI 和数据绑定的代码,设置window 上的标题有效,但 window 没有最大化,为什么?
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/
我创建了一个 JFace ApplicationWindow,我希望它最大化打开,但它不起作用,基本代码结构如下所示,我只是删除了创建 UI 和数据绑定的代码,设置window 上的标题有效,但 window 没有最大化,为什么?
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/