DevFaqWindowsMaximizeViaCode

How to maximize a TopComponent?

Example: How to open the output window in maximized state?

//----open/focus the TC "OutputWindow"
TopComponent tc = WindowManager.getDefault().findTopComponent("output");
if (!tc.isOpened()){ tc.open();}
tc.requestActive();

//----invoke the maximize action on the previously focused TC
//new way >=7.2
Action action=org.openide.awt.Actions.forID("Window", "org.netbeans.core.windows.actions.MaximizeWindowAction"); 
//OLD way <7.2
//Action action = FileUtil.getConfigObject("Actions/Window/org-netbeans-core-windows-actions-MaximizeWindowAction.instance", Action.class);

action.actionPerformed(null);

"But it's a hack, not a pretty API:) "

PS: For minimize use

 Action action=org.openide.awt.Actions.forID("Window", "org.netbeans.core.windows.actions.MinimizeWindowAction"); 

Taken from platform-dev mailing list

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo