Home > OS >  Is there a way to disable minimize/maximize button on shell in java
Is there a way to disable minimize/maximize button on shell in java

Time:10-19

i want to disable minimize and maximize button on shell. I try to use setminimize function but it doesnt work. How can i do? Thank for your answers.

Shell shell=new Shell();
shell.setsize( 800,600);
shell.setMaximized(false); 
shell.setMinimized(false);
shell. setVisible(false);

Browser browser = new Browser(shell, SWT. ON_TOP) ;
browser. setUrl (helpDoc);
browser.setBounds(10,10,
764, 541);
Display display = Display getDefault); shell.open();
shell. layout();

CodePudding user response:

You set the "style" of the Shell using the style parameter of the Shell constructor. The style specifies if the Min/Max buttons are shown. Once the shell has been created you can't change the style.

Your:

Shell shell = new Shell();

is equivalent to:

Shell shell = new Shell(SWT.SHELL_TRIM);

SWT.SHELL_TRIM style is defined as:

public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE;

So it includes the Close button, window title, min, max buttons and allows resizing.

A common style for dialogs is SWT.DIALOG_TRIM:

public static final int DIALOG_TRIM = TITLE | CLOSE | BORDER;

Which leaves out the min / max.

Note: These flags are just hints to the operating system window manager. The window manager may choose to show the buttons any way. For example, on macOS min and max are always shown but min is disabled for SWT.DIALOG_TRIM.

  • Related