Create a Floating/Undocked Non-sigleton Window in Netbeans

first of all some really useful links on this topic:

http://netbeans.dzone.com/news/secrets-netbeans-window-system

https://blogs.oracle.com/geertjan/entry/case_study_customizing_the_netbeans

http://forums.netbeans.org/ptopic15413.html


To create a TopComponent which is undocked by default, one need to define an undock (or floating ) mode.

To do so, create a new XML file and call it "newModeUnDock.xml"

Wriet following in the file:


<?xml version="1.0" encoding="UTF-8"?>
<mode version="2.3">
    <name unique="newModeUnDock" />
    <kind type="editor" />
    <state type="separated" />
    <constraints>
        <path orientation="vertical" number="0" weight="0.5"/>
        <path orientation="horizontal" number="1" weight="0.5"/>
    </constraints>
    <bounds x="312" y="237" width="679" height="378" />
    <frame state="0"/>
    <active-tc  id="ShowAllStats" />
    <empty-behavior permanent="true"/>
</mode>

Now register this file in layer.xml, under Windows2/Mode :

</folder>
            <file name="newModeUnDock.xml" url="newModeUnDock.xml"/>
 </folder>

and save layer.xml

Alternatively, Expand layer.xml,/<this layer> or <this layer in context>/Windows2/Mode, and make a new file there with the above name and content. and save layer.xml file.

Now, in the TopComponent add :

@Override
    public void open() {
        Mode mode = WindowManager.getDefault().findMode("newModeUnDock");
        mode.dockInto(this);
        super.open();
    }
save and run, there will be a floating window.

To hide the tabs in the undock window, simply follow these two blogs:

https://blogs.oracle.com/geertjan/entry/farewell_to_space_consuming_weird

http://www.pellissier.co.za/hermien/?p=597

Comments

Popular posts from this blog

Printing of large double values in JAVA with or without scientific notation

To increase the size of heap memory for a Netbeans project

Adding/Updating Java projects from existing sources to Netbeans Project