If you have a use case, where you want to compute
dialog/wizard size based upon the system client area(system resolution),then
the following is the general approach.
Rectangle clientArea = Display.getDefault().getClientArea();
int x_hint = (int) (0.7 * clientArea.width); //% based on
the required size
int y_hint = (int) (0.7 * clientArea.height));//% based on
the required size
GridDataFactory.fillDefaults().grab(true, true).hint(x_hint,
y_hint).applyTo(this);
The problem comes with above approach is, if your primary
monitor is connected with another monitor in extended mode display, then the
dialog/wizard may stretch to the extended monitor also, considering system
calculates the both monitors width as a display area.
To avoid this kind of issues, you can get primary monitor
display area and compute based on that.
Monitor primaryMonitor =
Display.getDefault().getPrimaryMonitor();
Rectangle clientArea = primaryMonitor.getClientArea(); //Now
compute based on this.
No comments:
Post a Comment