Where to specify the position of the window component?

I created a module in the netBean platform, then created a window component there, and I want to specify the default position in the main window. For exapmle position is "editor". Where can i do this?

+3
source share
2 answers

It doesn't look like NB WindowManager has a way to specify the position for the window in a way similar to what you are asking. The screen is divided into areas (known as modes), and there are methods that allow you to position the / TopComponent window in mode.

There is a document that provides a good overview of the NB window system . It has links to more detailed information that will help you.

Edit:

Another strategy used to rearrange the window is to edit the layer file associated with your module. This file is usually called "layer.xml".

Find the entry as shown below.

<folder name="Windows2">
    <folder name="Components">
        <file name="MyEditorWindowTopComponent.settings" url="MyEditorWindowTopComponentSettings.xml"/>
    </folder>
    <folder name="Modes">
        <folder name="editor">
            <file name="MyEditorWindowTopComponent.wstcref" url="MyEditorWindowTopComponentWstcref.xml"/>
        </folder>
    </folder>
</folder>

Change the name of the subfolder in the "Modes" section to match the desired value as a new position / mode ...

+1
source

In NetBeans 7, to switch from an output position to an "editor" position:

In your Window class, change the annotation

@TopComponent.Registration(mode="output", openAtStartup = true)

to

@TopComponent.Registration(mode="editor", openAtStartup = true)

Then you need to clean and rebuild. If you do not clear it, for some reason it will not pick up the changes - perhaps caching.

+4

Source: https://habr.com/ru/post/1735823/


All Articles