How to Customize the Close and Maximize Button in Eclipse Rcp
There are times when you just want your eclipse rcp in the middle of the screen. To do that you have to set the style bits for the window...
https://www.czetsuyatech.com/2009/11/java-eclipse-rcp-customize-close-maximize-buttons.html
There are times when you just want your eclipse rcp in the middle of the screen. To do that you have to set the style bits for the window's shell to customize the look of your window.
The API is accessible here: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/index.html, the setShellStyle method. It accepts different parameters such as SWT.CLOSE, SWT.MIN, SWT.MAX, SWT.TITLE, etc. For example we only want the Title in the window we will call the method like this:
configurer.setShellStyle(SWT.TITLE);
You can try several variations, another example is if you only want the close and the minimum buttons:
configurer.setShellStyle(SWT.TITLE | SWT.CLOSE | SWT.MIN);
For more style bits look at the SWT class API, and see what other values you can use.
BTW, always remember that: "This method has no effect after the shell is created. That is, it must be called within the preWindowOpen callback on WorkbenchAdvisor." [eclipse.org api]
The API is accessible here: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/index.html, the setShellStyle method. It accepts different parameters such as SWT.CLOSE, SWT.MIN, SWT.MAX, SWT.TITLE, etc. For example we only want the Title in the window we will call the method like this:
configurer.setShellStyle(SWT.TITLE);
You can try several variations, another example is if you only want the close and the minimum buttons:
configurer.setShellStyle(SWT.TITLE | SWT.CLOSE | SWT.MIN);
For more style bits look at the SWT class API, and see what other values you can use.
BTW, always remember that: "This method has no effect after the shell is created. That is, it must be called within the preWindowOpen callback on WorkbenchAdvisor." [eclipse.org api]
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { super(configurer); } public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { return new ApplicationActionBarAdvisor(configurer); } public void preWindowOpen() { IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); configurer.setShellStyle(SWT.TITLE | SWT.CLOSE | SWT.MIN); configurer.setShowCoolBar(false); configurer.setShowStatusLine(false); configurer.setTitle("Administrator Tool"); } }
2 comments
Hi,
I am not able to use SWT's methods(configurer.setShellStyle(SWT.TITLE | SWT.CLOSE | SWT.MIN);) method in this class. Please help me.
It's not working in the genome. If you have any suggestion, please share to me.
Post a Comment