Skip to main content

Disable/Restrict the user from resizing the JFace application window.

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.

  • 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.
  • A sample application window code will be generated with default configurations. 
  • Run the application and see if it is running successful. Right click on the java file and select Run As -> Java Application

  • 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 
  1. 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

Popular posts from this blog

Get your space from Seedr

Seedr: Get your space Seedr simplifies the way you get stuff, stream and access it. You can download it and use it right away. Below are the steps on how we can make use of Seedr Creating a free login Enter into the official website https://www.seedr.cc/ Create a free account by entering your email and a custom password for seedr in the main page as shown below Register on Seedr Once you submit the details you will get a confirmation email and click on the link sent by seedr to activate the account. Now you can login to your account and you can see that you have an free account with the usage limit upto 2 GB of space.  You can upgrade for getting more space. Visit https://www.seedr.cc/subscription for more details. Features of Seedr Access your Torrent Downloads easily Seedr has various ways of adding files to your storage. You can add Seedr to chrome via extension. Please visit  https://www.seedr.cc/pulse/2015/06/21/add-on/ for more details

Creating a System Tray notification with icon in Java

The Java language provides support for creating a popup notification with icon ad message. This can be done using many libraries in Java. Here I am going to demonstrate a simple way using AWT SystemTray . SystemTray class in Java: The SystemTray class represents the system tray for a desktop. On Microsoft Windows it is referred to as the "Taskbar Status Area", on Gnome it is referred to as the "Notification Area", on KDE it is referred to as the "System Tray". The system tray is shared by all applications running on the desktop.  On some platforms the system tray may not be present or may not be supported, in this case SystemTray.getSystemTray() throws UnsupportedOperationException. To detect whether the system tray is supported, use SystemTray.isSupported() method which returns true is it is supported.  For example: if (SystemTray.isSupported()) { System.out.println("System tray supported for this one!");         } else {