且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

向 SceneBuilder 2.0 添加自定义组件

更新时间:2022-11-19 08:08:50

如果问题只是让您的自定义类在 SceneBuilder 中可用,您可以通过以下步骤来实现:

If the issue is just to make your custom class available in SceneBuilder, you can do so with the following steps:

  1. 将您的自定义类(以及任何支持类,例如 Annotation)捆绑为一个 jar 文件
  2. 在 SceneBuilder 中,激活左窗格顶部库"旁边的下拉按钮:
  3. 选择导入 JAR/FXML 文件..."
  4. 选择在步骤 1 中创建的 Jar 文件
  5. 确保您需要在 SceneBuilder (PaneWithSelectionListener) 中访问的类被选中
  6. 按导入组件"
  7. PaneWithSelectionListener 现在将出现在左窗格中自定义"下的 SceneBuilder 中:
  1. Bundle your custom class (and any supporting classes, such as Annotation) as a jar file
  2. In SceneBuilder, activate the drop-down button next to "Library" in the top of the left pane:
  3. Choose "Import JAR/FXML File..."
  4. Select the Jar file created from step 1
  5. Make sure the class you need access to in SceneBuilder (PaneWithSelectionListener) is checked
  6. Press "Import Component"
  7. PaneWithSelectionListener will now appear in SceneBuilder under "Custom" in the left pane:

您会注意到 SceneBuilder 中的下拉菜单有一个自定义库文件夹"选项,您可以从中打开存储 jar 文件的文件夹.对于快速选项,您可以将 jar 文件复制到此文件夹中,并且(经过短暂延迟后),所包含的类将出现在自定义"列表中.

You'll notice the drop-down in SceneBuilder has a "Custom Library Folder" option, from which you can open the folder where the jar files are stored. For a quick option, you can just copy jar files to this folder and (after a short delay), the contained classes will appear in the "Custom" list.