javaswingnetbeansnetbeans-platform

NetBeans platform default TopComponent positioning as anonymousMode_1


how do i set default position of two TopComponents in 'editor' mode not in tabs, like this:

tabbed

but one next to each other; like this:

paned

?


Solution

  • The key to solving this problem was in creating two new different modes with the same desired kind of "editor", same vertical and horizontal "weights", but different horizontal "numbers". Here is how:

    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>
    

    And here is registration of two .wsmodes in the layer.xml:

    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>
    

    Now it is possible to use

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

    and

    @TopComponent.Registration(mode = "Mp3PaneRight", openAtStartup = true,position = 20)
    

    annotations for left and right TopComponent panes respectively.

    Also do not forget to clean-build your porject each time you changing this defaults - they're persistently getting overridden by user re-positioning of TopComponents easily.