Baz
Baz

Reputation: 36884

JFace Dialog maximize programmatically

I am currently trying to maximize a JFace Dialog programmatically. Usually calling setMaximized(true) on the parentShell of the Dialog would be sufficient to achieve this.

However, it does not work for my Dialog. Maximizing it manually using the window buttons works.

Does anybody have an idea how to do it?

Upvotes: 2

Views: 1720

Answers (1)

Serrega
Serrega

Reputation: 176

Try to do following:

Rectangle bounds = parentShell.getDisplay().getClientArea();
myDialog.setBounds(bounds);
parentShell.setMaximized(true);

UPD: But this approach is not fairly true as this code breaks previous size of you dialog. Following approach seems to work better:

parentShell.pack();
parentShell.setMaximized(true);

Upvotes: 2

Related Questions