java 在 NetBeans IDE 上将组件添加到调色板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11200391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 04:12:11  来源:igfitidea点击:

Adding component to palette on NetBeans IDE

javaswingnetbeansnetbeans-platformjcalendar

提问by Blueberry

I am looking at the NetBeans Platform using NetBeans IDE to create a Swing UI application.

我正在查看使用 NetBeans IDE 创建 Swing UI 应用程序的 NetBeans 平台。

I am trying to get a jCalendar component into the palette and onto my window. The problem is that if I attempt to drag it onto the form I get an error saying it is not included as a dependency on my module.

我正在尝试将 jCalendar 组件放入调色板和我的窗口中。问题是,如果我尝试将它拖到表单上,我会收到一条错误消息,指出它不作为对我的模块的依赖项包含在内。

enter image description here

在此处输入图片说明

So I thought no problem, I will add it, however, even though it is in the palette and getting it there involves creating it as a library, when I attempt to go to Add Dependency under project properties / Libraries, it is not in the list of Libraries to choose from!

所以我认为没问题,我会添加它,但是,即使它在调色板中并且将它放在那里涉及将其创建为库,当我​​尝试转到项目属性/库下的添加依赖项时,它不在可供选择的图书馆列表!

enter image description here

在此处输入图片说明

The project is a NetBeans Module, and when I create this in a regular java project, I can find it in the list. I can also see it in the Library Manager, but not in the properties of a NetBeans Module.

该项目是一个 NetBeans 模块,当我在常规 java 项目中创建它时,我可以在列表中找到它。我也可以在库管理器中看到它,但在 NetBeans 模块的属性中看不到。

enter image description here

在此处输入图片说明

Any ideas why I can not get this library added here?

为什么我不能在这里添加这个库的任何想法?

P.S. I was trying to use this tutorial to get this picker onto my palette. I assume the difference is, his project isn't a NetBeans Platform one? http://greenxgene.blogspot.co.uk/2012/04/how-to-use-jcalendar-date-picker-in.html

PS 我试图使用本教程将这个选择器放到我的调色板上。我认为不同之处在于,他的项目不是 NetBeans 平台项目吗? http://greenxgene.blogspot.co.uk/2012/04/how-to-use-jcalendar-date-picker-in.html

回答by Tim Sparg

I think the root of the problem is that you need to create a "Library Wrapper Module"

我认为问题的根源在于您需要创建一个“库包装模块”

This wraps your jCalendar jar and creates a NetBeans module out of it.

这将包装您的 jCalendar jar 并从中创建一个 NetBeans 模块。

New Project Dialog

新建项目对话框

After that you should be able to add the item to your form.

之后,您应该能够将该项目添加到您的表单中。

回答by m4heshd

There's a way easier method than writing wrappers.

有一种比编写包装器更简单的方法。

  1. Go to Tools -> Palette -> Swing / AWT Components.

  2. Create new category named JCalender

  3. Hit Add from JAR and just follow the simple steps.

  1. Tools -> Palette -> Swing / AWT Components.

  2. 创建名为的新类别 JCalender

  3. 从 JAR 中点击 Add 并按照简单的步骤操作。

That's all. And you'll have this sweet view :

就这样。你会看到这个甜蜜的景色:

JCalender in Pallet

托盘中的 JCalender

回答by SorinS

To add your library to the libraries palette, do this:

要将您的库添加到库调色板,请执行以下操作:

  • go to Tools/Libraries
  • press New Library
  • set a Library Name and choose Class Libraries as a Library Type
  • press the Add JAR/Folder button and add all the jars that would form your library (add sources and java docs using the other tabs as well)
  • press Ok and you're done
  • 转到工具/库
  • 按新图书馆
  • 设置库名称并选择类库作为库类型
  • 按“添加 JAR/文件夹”按钮并添加将构成您的库的所有 jar(也使用其他选项卡添加源和 java 文档)
  • 按确定,你就完成了

If you want to use the library for Netbeans Platform development, do as Tim mentioned.

如果您想使用该库进行 Netbeans 平台开发,请按照 Tim 所述进行操作。