Where to specify window component's position?

泄露秘密 提交于 2019-12-12 16:12:20

问题


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


回答1:


It does not look like the NB WindowManager has a way to specify a position for a window in a manner similar to what you are asking. The screen is broken up into areas (known as modes) and there are methods that let you position a window/TopComponent into a mode.

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

Edit:

Another strategy to use to reposition a window is to edit the layer file associated with your module. This file is usually called 'layer.xml'.

Look for an entry like the following

<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 under "Modes" to match the value that you want as the new position/mode...




回答2:


Under NetBeans 7, to change from 'output' position to '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 don't clean it, it won't pick up the changes for some reason - probably caching.



来源:https://stackoverflow.com/questions/2397991/where-to-specify-window-components-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!