I want to manage viewing top components taps using code without need to click the tab, I have four top components, three of them are "editor" top component and the last one is explorer top component when I click button in it I want to control which of the three "editor" be viewed (selected) I'm using Netbeans Platform
image top components(package contents,Viewer,Add Metadata and Add Resources)
this.parent get the top components Parent
this.getParent() = (javax.swing.JPanel) javax.swing.JPanel[Content displayer,0,30,1110x720,invalid,
layout=org.netbeans.swing.tabcontrol.plaf.StackLayout,alignmentX=0.0,alignmentY=0.0,
border=javax.swing.border.MatteBorder@b3f746,flags=9,maximumSize=,minimumSize=,preferredSize=]
First You need to find Your topcomponent. You can use this method:
WindowManager.getDefault().findTopComponent("YourTopComponentPreferredId")
or You can iterate over the opened topcomponents with this method:
WindowManager.getDefault().getRegistry().getOpened()
and select that You need.
After You have the TopComponent call open()
and requestActive()
methods on it.