netbeans:NetBeans Property Editor Tutorial来源: 发布时间:星期四, 2009年1月8日 浏览:11次 评论:0
This tutorial shows techniques for using property editors in NetBeans, including providing custom editors and custom inplace editors. Spec
![]() Providing your own property editor for an individual Node Creating a custom editor Creating a custom inplace editor Registering a custom property editor globally To follow this tutorial, you need the software and resources listed in the following table. Software or Resource Version Required NetBeans IDE version version 6.1 or version 6.0 Java Developer Kit (JDK) version 6 or version 5 Optionally, for troubleshooting purposes, you can download the completed sample. Introduction to Custom Property Editors Often you may have a property for which either the standard property editor is not sufficient, or the property type is a ![]() ![]() ![]() This tutorial is ![]() Registering DatePropertyEditor Globally Often it is useful to register a property editor to be used for all properties of a given type. Indeed, your DatePropertyEditor is generally useful for any property of the type java.util.Date. While usefulness is not the primary determinant of whether such a property editor should be registered, ![]() Here is how to register DatePropertyEditor so that any property of the type java.util.Date will use DatePropertyEditor in the property sheet: Right click the My Editor project, and choose Properties from the popup menu. On the Libraries page of the project properties dialog, click Add Dependency—you need to add a dependency on the Module ![]() ![]() ![]() Right click the org.myorg.myeditor package in the My Editor project and choose New > Other. Under the NetBeans Module Development category, select Module Installer. Click Finish. A sub ![]() ![]() Implement the restored ![]() public void restored This code will register DatePropertyEditor as the default editor for all properties of the type java.util.Date throughout the system. Press Ctrl-Sh ![]() Remember, you should only do this ![]() ![]() If the type you want to provide a property editor for is in your module, it may be preferable to place the registration code in a ![]() ![]() public Caveat: If you are not sure your property editor will be used during a typical session, a better technique may be to use PropertyEditorManager.![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Using PropertyPanel While you won't cover it in great detail, it is worth mentioning that the property sheet is not the only place that Node.Property objects are useful; there is also a convenient UI ![]() ![]() ![]() ![]() 0
相关文章
读者评论发表评论 |
|