2

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

标签式

但一个挨着一个;像这样:

窗格

?

4

1 回答 1

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 中两个 .wsmode 的注册:

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 持续覆盖。

于 2012-05-02T06:25:13.987 回答