java - 如何使用 Swing 组件的自定义子类?我需要将它安装到调色板吗?

标签 java swing netbeans javabeans netbeans-plugins

如何将 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)声明它。

enter image description here

最佳答案

您可以将自定义组件添加到 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/

相关文章:

java - Json Jackson 不反序列化内部对象(属性上为 null)

java - 为什么不推荐使用 "using getString() to get device identifiers"?

java - 在 JTable 中使用空列作为分隔符

java - 如果没有更改则跳过 DLL 编译

php - Netbeans 和 PHP; class_alias 和代码完成

Java 版本与 Protobuf 冲突

java - Android 与 ReSTLet/JSON/Jackson 的兼容性

java - 如何在JTable中显示图像?

java - 从 netbeans 的 main 方法中操作 jLabel

java - 导入 org.postgresql.jdbc3.Jdbc3PoolingDataSource