我使用 netbeans 平台设计了一个小应用程序,现在我想更改 netbeans 平台提供的基本布局的方向。我有一个窗口显示如下所示
我希望上面的屏幕在启动时显示如下。我已调整大小以满足我的需要,但我希望它自行发生。
经过大量谷歌搜索后,我发现我需要创建一个 layer.xml
在其中一个模块中添加以下代码。
<folder name="Windows2">
<file name="WindowManager.wswmgr" url="WindowManager.wswmgr"/>
</folder>
我的 WindowManager.wswmgr
文件看起来像这样
<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" />
我现在该怎么办?我错过了一些明显的东西吗??
--编辑--
图层.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>
最佳答案
WindowManager.wswmgr
文件定义主窗口的属性。您需要定义的另一部分是资源管理器模式(假设 CustomerViewer 窗口处于资源管理器模式)。
定义和注册模式类似于您定义和注册 WindowManager.wswmgr
的方式。文件。确定 xml 应该是什么样子的实用方法¹是运行应用程序,将分隔符移动到所需位置,关闭应用程序,然后从文件资源管理器中打开以下文件 <Your_NB_Application>/build/testuserdir/config/Windows2Local/Modes/explorer.wsmode
.
从 explorer.wsmode
复制内容到名为 explorer.wsmode
的文件中您可以在模块的根包 ( com.example.mymodule
) 中创建它。现在你需要在你的层文件中注册这个文件:
<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>
请务必在您的应用程序上运行“Clean and Build All”,然后再次运行它。
¹确定结构的正式方法是使用位于http://www.netbeans.org/dtds/mode-properties2_4.dtd 的dtd。
关于java - Netbeans 平台布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10344724/