llTtoOmMll
llTtoOmMll

Reputation: 67

Minimum size of swt shell and components

How can I set a minimum size of the shell in swt? For example I have added a search field in my shell but I can shrink the shell almost completely and then the search field isn't completely visible. Can I change a property of the search field to stop resizing if it would be unseen?

Upvotes: 0

Views: 330

Answers (1)

greg-449
greg-449

Reputation: 111142

No, there isn't any property or anything like that to prevent the resizing.

You can use Shell.setMinimumSize to set a minimum width.

Update The following resize code from the original version of this answer doesn't work as resize is called after the window is resized

shell.addListener(SWT.Resize, event -> {
  Shell eventShell = (Shell)event.widget;

  Point size = eventShell.getSize();

  if (size.x < 100 || size.y < 100)
   {
     // Stop the resize event
     event.doit = false;
   }
});

Upvotes: 0

Related Questions