Below are the steps if you would like to Disable/Restrict the user from resizing/maximize/minimize the JFace application window.
Step 1: Create a sample JFace Application window.
Step 1: Create a sample JFace Application window.
- Open Eclipse and go to File --> Other
- New wizard dialog opens asking you to select the project type. Go to WindowBuilder -> SWT Designer -> SWT/JFace Java Project (If you are not having the window builder plugin enabled in your eclipse please go through this link https://o7planning.org/en/10105/install-windowbuilder-into-eclipse to install window builder)
- Click Next and provide a valid project name and click finish to create a SWT/Jface project.
- Project gets created in your workspace, create a package in the src folder and right click on the package and select New -> other and select WindowBuilder -> SWT Designer -> JFace -> ApplicationWindow.
- Click Next and provide a valid ApplicationWindow name "SampleWindow" and click Finish.
- Application should run and brings up a application window similar as shown below.
- Now some users prefer not to resize the application window (or) disable the resize option for the application window. We can achieve that by Overriding the getShellStyle() method and returning the shell style with (~SWT.RESIZE). Add the following snippet in your ApplicationWindow code. Now run the application and see the changes. User will not be able to do resize of the application window.
@Override
protected int getShellStyle() {
return super.getShellStyle() & (~SWT.RESIZE);
}
- Few users prefer not to provide minimize (or) maximize button for their application window thus maintaining the custom size. We can achieve that by doing the following
- Add the line "setShellSyle(SWT.CLOSE | SWT.MIN)" to the code to disable the maximize option for the application.
- Similarly change the line to "setShellSyle(SWT.CLOSE | SWT.MAX)" to the code to disable the minimize button for the application.
Comments
Post a Comment