我有一个相当复杂的 JTable 子类(WidgetTable
及其WidgetTableModel
),当我将它添加到虚拟 JPanel 以进行测试时,它可以正常工作。
由于我非常讨厌使用 LayoutManagers,因此我喜欢使用 NetBeans 内置的 GUI Builder 来完成我的所有布局工作。然后我通常只是围绕自动生成的(GUI builder)代码编写代码,这对我来说一直有效。这是两全其美的:我的演示文稿看起来完全符合我的要求,而且我还可以对组件进行细粒度的控制。
但是,我从未使用过 GUI Builder 工具来制作表格。在昨晚修补了一段时间之后,它看起来好像只适用于制作非常基本的(固定的行数,固定的列数等)JTables。
我WidgetTable
实际上有动态数量的行和列、特殊的编辑器/渲染器和许多其他的花里胡哨。
我的问题:
I have two conflicting constraints: (1) I need to use the GUI builder to position and size the table exactly where I want it in the container, but, (2) The table component available through the GUI builder is too basic to handle my WidgetTable
.
I need a way to design a "table placeholder" into my container with the GUI builder, such that, once NetBeans autogenerates that placeholder code, I tweak the code and instruct it to dynamically instantiate one of my WidgetTables
instead, consuming the location and size that I defined the placeholder component to take up.
This way I can have my cake, and eat it too. The only problem is, I don't think the GUI builder supports this ability to drag-n-drop abstract JComponents
, position and size them, and then plug subclasses into them elsewhere in the codebase.
Anybody ever have this problem before or have any interesting recommendations? I imagine the best thing to do would be for me to just roll up my sleeves and learn LayoutManagers, but I'm mostly a server-side developer and only come over to the client-side every once in a blue moon; and honestly, don't have the energy to learn the intricacies and nastiness of GroupLayout and its sinister cousins.
Thanks for any help!