如何将 NewJPanel(一个 Netbeans 生成的扩展 JPanel 的类)添加到 GUI 构建器的调色板?
目标是能够通过调色板添加 NewJPanel,使其具有 NewJPanel 类型而不是 JPanel 类型。但是,正如我所期望的那样,它不能通过调色板使用。
我正在关注:
To install via Palette Manager
Open the Palette Manager from main menu: Tools | Palette Manager | Swing/AWT Components In the Palette Manager press button according to where the component comes from. The choices are: from an external JAR file from a library defined in the IDE (always create a library if the components need more than one JAR) from a NetBeans project
来自 Netbeans FAQ's .
此方法不起作用,因为这些类无法选择。
但是,我能够将 NewJPane 拖到 NewJFrame 的设计 View 上,在该 View 中使用正确的 NewJPane 类型(而不是 JPane)声明它。
最佳答案
您可以将自定义组件添加到 matisse GUI 面板。
Build your project so the class file you want to use is part of the jar file
Open a java class that has a form, and switch to design mode. 3, Right click in the palatte and choose "palatte manager".
Choose the "add from jar" button to select your jar.
Choose the class you made, and add it to your palatte.
现在 netbeans 已识别您的面板,您可以将其拖动到新面板中。
关于java - 如何使用 Swing 组件的自定义子类?我需要将它安装到调色板吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10495585/