sandip chitale's blog    Sandip Chitale's blog (scblog)
NOTE: I have moved many of my modules to NetBeans Plugin Portal . Please check there for latest versions of modules described on this blog.
20071123 Friday November 23, 2007

Tip: api to show Java type chooser dialog in NetBeans 6.0

While implementing the Add Property module, Jan Lahoda pointed out an api available in NetBeans 6.0 Java support which can show a Java Type chooser dialog. Here is the snippet of code to show the dialog:

        FileObject fileObject = ...; // Some java file's file object in a NetBeans Project.

ElementHandle<TypeElement> type = TypeElementFinder.find(ClasspathInfo.create(fileObject), null);

if (type != null) {
// use the type somehow

which shows the dialog:

Find Type dialog

You can use this api in your module any time you want to select a Java type. You will have to add the following dependencies to your module:

  • Java Source
  • Java Source UI
  • Java Support APIs
  • Javac API Wrapper

The TypeElementFinder api is implemented in Java Source UI module. You can further customize the dialog by passing the second argument to the find() method.

For some reason this does not appear in the NetBeans 6.0 API docs - probably because this is not an official API yet.


Posted by sandipchitale ( Nov 23 2007, 09:36:49 PM PST ) Permalink Comments [0]


Trackback URL: http://blogs.sun.com/scblog/entry/tip_api_to_show_java
Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed








« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 363


XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

scblog
scblog