Wednesday, September 9, 2009

Center a SWT Shell on the screen

Below snippet of code can be used to center a SWT shell on the screen

//center the dialog screen to the monitor
Monitor primary = display.getPrimaryMonitor ();
Rectangle bounds = primary.getBounds ();
Rectangle rect = shell.getBounds ();
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
shell.setLocation (x, y);

shell.open();
shell.layout();

Below link will provide a brief idea about creating a splash screen using SWT

http://www.eclipsezone.com/eclipse/forums/t53291.html

1 comment:

  1. Отличный код .. уважуха ...

    Тольк какjго хрена в самом SWT нет стандартных средств ?!?!?!?

    ReplyDelete