How to maximize a TopComponent?

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

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