9

I have designed a little application using netbeans platform and now i want to change the orientation of the basic layout provided by netbeans platform. I have a window displaying like this shown below enter image description here

I want the abouve screen to be displayed like below on the startup. I have resized to suit my needs but i want that to happen by itself.

enter image description here

After intense googling i found that i need to create a layer.xml in one of the module and add the following code to it.

<folder name="Windows2"> <file name="WindowManager.wswmgr" url="WindowManager.wswmgr"/> </folder>

My WindowManager.wswmgr file looks like this

<windowmanager version="2.1">
<main-window> 
    <joined-properties centered-horizontally="true" centered-vertically="true"
                       width="630" height="400" />
    <separated-properties centered-horizontally="true" relative-y="0.1"
                       relative-width="0.6" relative-height="0.08" />
</main-window>
<editor-area state="joined">
    <constraints>
        <path orientation="horizontal" number="60" weight="0.5" />
        <path orientation="vertical" number="40" weight="0.7" /> 
        <path orientation="horizontal" number="40" weight="0.5" /> 
    </constraints>
    <relative-bounds x="33" y="24" width="42" height="44"/>
</editor-area>
<screen width="1024" height="800" />
<active-mode name="explorer" />
<maximized-mode name="" />
<toolbar configuration="Standard" preferred-icon-size="24" />

What do i have to do now? Am I missing some obvious things ??

--EDIT--

layer.xml

<filesystem>
<folder name="Actions">
    <folder name="Window">
        <file name="org-choose-transaction-ChooseTransactionTopComponent.instance_hidden"/>
        <file name="org-choose-transaction-EnterAmountTopComponent.instance">
            <attr name="instanceCreate" methodvalue="org.openide.windows.TopComponent.openAction"/>
            <attr name="preferredID" stringvalue="ChooseTransactionTopComponent"/>
        </file>
        <file name="org-prowze-maketransaction-TransactionTopComponent.instance">
            <attr name="instanceCreate" methodvalue="org.openide.windows.TopComponent.openAction"/>
            <attr name="preferredID" stringvalue="transactionTopComponent"/>
        </file>
        <file name="org-prowze-maketransaction-transactionTopComponent.instance_hidden"/>
    </folder>
</folder>
<folder name="Toolbars_hidden"/>

<folder name="Windows2">
    <folder name="Modes">
        <file name="explorer.wsmode" url="explorer.wsmode"/>
        <folder name="explorer"/>
    </folder>   
    <file name="WindowManager.wswmgr" url="WindowManager.wswmgr"/>
</folder>

explorer.wsmode

<mode version="2.4">
<module name="org.netbeans.core.ui/1" spec="1.2" />
<name unique="explorer"  />
<kind type="view" />
<state type="joined"  />
<constraints>
    <path orientation="horizontal" number="20" weight="0.3"/>
    <path orientation="vertical" number="20" weight="0.5"/>
</constraints>
<bounds x="192" y="228" width="614" height="520" />
<frame state="0"/>
<active-tc  id="CustomerViewerTopComponent" />
<empty-behavior permanent="true"/></mode>
Deepak
  • 6,684
  • 18
  • 69
  • 121
  • 1
    I am not 100% sure but: I think if you make your TopComponent have a minimum size (implement `getMinimumSize()` to take your graphics into account) and activate the "Respect mininum size" in your application "Branding" properties then this should be happening automatically. –  Apr 27 '12 at 09:46
  • 1
    Respect Minimum size has effect only when resizing.. I have tried that actually!! – Deepak Apr 27 '12 at 09:52

1 Answers1

3

The WindowManager.wswmgr file defines the main window's attributes. The other piece that you need to define is the explorer mode (assuming that the CustomerViewer Window is in the explorer mode).

Defining and registering a mode is similar to how you've defined and registered the WindowManager.wswmgr file. The pragmatic way¹ of determining what the xml should look like is to run the application, move the divider to the desired position, close the application, and open the following file from the Files explorer<Your_NB_Application>/build/testuserdir/config/Windows2Local/Modes/explorer.wsmode.

Copy the contents from the explorer.wsmode into a file named explorer.wsmode which you can create in the module's root package (com.example.mymodule). Now you need to register this file in your layer file:

<folder name="Windows2"> 
    <file name="WindowManager.wswmgr" url="WindowManager.wswmgr"/> 
    <folder name="Modes">
        <file name="explorer.wsmode" url="explorer.wsmode"/>
        <folder name="explorer"/>
    </folder>        
</folder>

Be sure to run "Clean and Build All" on your application before running it again.

¹The formal way for determining the structure is to use the dtd located at http://www.netbeans.org/dtds/mode-properties2_4.dtd

Jonathan Spooner
  • 7,682
  • 2
  • 34
  • 41
  • The path in my system is not `/build/testuserdir/Windows2Local/Modes/explorer.wsmode.` it is `/build/testuserdir/config/Windows2Local/Modes/explorer.wsmode.` – Deepak Apr 27 '12 at 09:26
  • I have done the steps and still it doesn work. I have posted my layer.xml and explorer.wsmode file as edit – Deepak Apr 27 '12 at 09:28
  • Actually the overridden explored.wsmode seems to be doing nothing or its not even recognised... – Deepak Apr 27 '12 at 09:37
  • From your edit, it looks like you didn't move the divider before you copied the contents of `explorer.wsmode`. It's hard to believe that the `horizontal` `weight` property could be exactly `0.3` after moving the divider. – Jonathan Spooner Apr 27 '12 at 09:40
  • 1
    Also, be sure to run "Clean and Build All" on your application. – Jonathan Spooner Apr 27 '12 at 09:43
  • actually i did!!! i moved the divider and copied!! Also if i change the 0.3 to 0.5 and nothing changed! – Deepak Apr 27 '12 at 09:45
  • When I moved the divider the only value changed was `` – Deepak Apr 27 '12 at 09:48
  • Hmmm, something else must be wrong. This technique works on my machine (NB 7.1). You could try starting a new app to test this technique and see if you can get it to work. – Jonathan Spooner Apr 27 '12 at 09:57
  • thanks for your help.. I will consider starting a bounty on this! – Deepak May 02 '12 at 00:50
  • I am trying to use this advice, but am at a loss as to where I should save the wsmode file. I tried placing it in the same directory as the source for that module. That didn't do anything. – Coding Junkee Jul 15 '13 at 19:22
  • You can put the `wsmode` file in any of your source packages - I recommend putting it in the module's root package. Then you need to let the platform know about this file by adding the entry in your layer file (this is the XML that I've posted in the answer and the `url` attribute is relative to your module's root package). If your module doesn't have a layer file then you'll need to create one by right clicking on your module > New > Other > Module Development > XML Layer. – Jonathan Spooner Jul 16 '13 at 02:46