I get no error.
The debugging breakpoint in ShowEditorOnlyAction.actionPerformed() is
reached and the method is executed:
@Override
public void actionPerformed( ActionEvent e ) {
EditorOnlyDisplayer eod = EditorOnlyDisplayer.getInstance();
eod.setActive( !eod.isActive() );
}
But there is no effect in GUI. Tab and Toolbars are still shown...
When I manually activate Main Window Tab and click menu "View - Show Only
Editor" it works...
*EDIT: Th*e following combination works (calling action after TopComponent
has opened and requested to be active):
import java.awt.event.ActionEvent;
import javax.swing.Action;
import org.openide.filesystems.FileUtil;
public final class MainTopComponent extends TopComponent {
@Override
protected void componentOpened() {
super.componentOpened();
requestActive();
}
@Override
protected void componentActivated() {
super.componentActivated();
Action action =
FileUtil.getConfigObject("Actions/Window/org-netbeans-core-windows-actions-ShowEditorOnlyAction.instance",
Action.class);
action.actionPerformed(new ActionEvent(this, 0, "dummy"));
}
}
and I had to add the following dependency to pom.xml:
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-filesystems</artifactId>
<version>RELEASE90</version>
</dependency>
So finally it was a timing problem: call action only after Tab/TopComponent
has opened AND is the active tab.
On Tue, Dec 22, 2020 at 11:53 PM Jerome Lelasseux <[email protected]>
wrote:
> What error do you get ?
>
>
>
> Le mardi 22 décembre 2020 à 22:32:23 UTC+1, Ralf Eichinger <
> [email protected]> a écrit :
>
>
> I tried
>
> @Override
> public void componentOpened() {
> Action action =
> FileUtil.getConfigObject("Actions/Window/org-netbeans-core-windows-actions-ShowEditorOnlyAction.instance",
> Action.class);
> action.actionPerformed(new ActionEvent(this, 0, "dummy"));
> }
>
> in my TopComponent class of my netbeans platform app.
> (this class:
> https://github.com/datazuul/eazy-bookscanner/blob/main/core/src/main/java/com/datazuul/bookscanner/core/MainTopComponent.java
> )
> sadly, no success.
>
> Where to place it? how to call it?
>
> On Tue, Dec 22, 2020 at 10:23 AM Patrik Karlström <[email protected]>
> wrote:
>
> Better yet, don't use tabs!
>
> https://blogs.oracle.com/geertjan/farewell-to-space-consuming-weird-tabs
> aka NoTabsTabDisplayerUI
>
>
> Den mån 21 dec. 2020 kl 14:18 skrev Ralf Eichinger <
> [email protected]>:
> >
> > I am developing a netbeans RELEASE90 platform based application.
> > all gui is placed in editor area.
> > Is there a way to programmatically call "Show Only Editor" (like in the
> > "view"-menu)
> > on startup of application?
> >
> >
>
>
>
> --
> Ralf Eichinger
> Georg-Lindau-Str. 5
> 80634 München
> tel: 089 / 2375 6862
> mobil: 0152 / 5368 5735
> email: [email protected]
>
--
Ralf Eichinger
Georg-Lindau-Str. 5
80634 München
tel: 089 / 2375 6862
mobil: 0152 / 5368 5735
email: [email protected]