NetBeans平台默认TopComponent定位为anonymousMode_1

时间:2012-04-30 07:58:46

标签: java swing netbeans netbeans-platform

如何在“编辑器”模式下设置两个TopComponents的默认位置而不是在标签中,如下所示:

tabbed http://www.pasteall.org/pic/show.php?id=31021

但彼此相邻;像这样:

paned http://www.pasteall.org/pic/show.php?id=31022

1 个答案:

答案 0 :(得分:4)

解决这个问题的关键是创建两个新的不同模式,使用相同的所需类型的“编辑器”,相同的垂直和水平“权重”,但不同的水平“数字”。方法如下:

Mp3PaneLeft.wsmode

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mode PUBLIC "-//NetBeans//DTD Mode Properties 2.3//EN" "http://www.netbeans.org/dtds/mode-properties2_3.dtd">
<mode version="2.3">
    <name  unique="Mp3PaneLeft" />
    <kind  type="editor" />
    <state type="joined" />
    <constraints>
        <path orientation="vertical" number="20" weight="0.2"/>
        <path orientation="horizontal" number="20" weight="0.5"/>
    </constraints>
    <empty-behavior permanent="true" />
</mode>

Mp3PaneRight.wsmode

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mode PUBLIC "-//NetBeans//DTD Mode Properties 2.3//EN" "http://www.netbeans.org/dtds/mode-properties2_3.dtd">
<mode version="2.3">
    <name  unique="Mp3PaneRight" />
    <kind  type="editor" />
    <state type="joined" />
    <constraints>
        <path orientation="vertical" number="20" weight="0.2"/>
        <path orientation="horizontal" number="40" weight="0.5"/>
    </constraints>
    <empty-behavior permanent="true" />
</mode>

这里是在layer.xml中注册两个.wsmodes:

layer.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
    <folder name="Windows2">
        <folder name="Modes">
            <file name="Mp3PaneLeft.wsmode" url="Mp3PaneLeft.wsmode"/>
            <file name="Mp3PaneRight.wsmode" url="Mp3PaneRight.wsmode"/>
        </folder>
    </folder>
</filesystem>

现在可以使用

@TopComponent.Registration(mode = "Mp3PaneLeft", openAtStartup = true, position = 10)

@TopComponent.Registration(mode = "Mp3PaneRight", openAtStartup = true,position = 20)
左侧和右侧TopComponent窗格的

注释。

每次更改此默认设置时,也不要忘记清理构建项目 - 它们会被用户轻松地重新定位TopComponents而被覆盖。