How to properly center an e4 Application Window? [message #632078] |
Mon, 11 October 2010 09:34  |
Eclipse User |
|
|
|
Hi,
I want to center my e4 application window (an instance of MTrimmedWindow). Currently, I call the following method in one of my parts.
@PostConstruct
public void init() {
if(app.getChildren().get(0) instanceof MTrimmedWindow){
MTrimmedWindow window = (MTrimmedWindow)app.getChildren().get(0);
Monitor primary = Display.getCurrent().getPrimaryMonitor();
Rectangle bounds = primary.getBounds();
Rectangle rect = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight());
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
window.setX(x);
window.setY(y);
}
}
It somehow works but it resets the window each time the part get's initialized.
So I wonder if there is an option somewhere in the application model where I can specify the "center window" option.
Thanks,
Matthias
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05473 seconds