Anonymous Class to Inner Class

One underhighlighted improvement in the upcoming NetBeans IDE 6.0 is that it will support keyboard users far more than before. When coding, I really hate having to break the flow of my activity by needing to call up dialog boxes and then having to click various things within them. Of course, there are ways of calling up those dialog boxes without using a mouse, but those keyboard combinations are a bit tricky and my life would be simpler if I could simply continue typing instead of needing to resort to dialog boxes. So, 6.0 comes to the rescue with its heavy focus on keyboard-based programming. Here's an example. You're adding an action listener to a JButton:

As one has been able to do in the past, one can let the IDE generate the required abstract methods, by simply clicking the hint that is shown above:

However, now I'm cleaning up my code and I don't want that class to be anonymous anymore. Instead, I want it to be an inner class. In the past, I'd have to call up a dialog box, click various things, and then the inner class would be created. In 6.0, I'll be able to simply select something in the anonymous class and then press Alt-Enter:

Then the small popup shown above appears. I simply press Enter again. And then... I have a new inner class:

And the anonymous class is transformed into a call to my inner class:

And if I don't like the name of my new inner class, I can simply click Ctrl-R over the name, and then I will be able to change the name, as well as references to it, in-line immediately, without any dialog boxes. Hurray!

Comments:

Features like those are nice, but almost unusable as they write the complete class path everywhere, e.g. "java.lang.String" instead of "String". And afterwards you can undo this crap. I hope it will have a smarter behaviour in the final release.

Posted by Philip on August 20, 2007 at 10:13 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today