Monday Jul 07, 2008

Prevent the Generation of Fully Qualified Class Names

One big improvement in 6.5 that you're unlikely to hear about (anywhere else) is this very significant improvement (among several others) in the NetBeans Matisse GUI Builder—you can let Matisse generate code without fully qualified names. That's something I've wanted a long time, as well as others I've seen commenting on this online.

Simply choose Tools | Options | GUI Builder and then uncheck the "Generate Fully Qualified Names of Classes" checkbox. The result is that when you, for example, create a new JFrame, you'll get the following code:

package demo;

import javax.swing.WindowConstants;
import org.jdesktop.layout.GroupLayout;

/\*\*
 \*
 \* @author geertjan
 \*/
public class NewJFrame extends javax.swing.JFrame {

    /\*\* Creates new form NewJFrame \*/
    public NewJFrame() {
        initComponents();
    }

    /\*\* This method is called from within the constructor to
     \* initialize the form.
     \* WARNING: Do NOT modify this code. The content of this method is
     \* always regenerated by the Form Editor.
     \*/
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        
        );

        pack();
    }// </editor-fold>

    /\*\*
    \* @param args the command line arguments
    \*/
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    // End of variables declaration

}

That's pretty cool and very welcome news. But there are several other options that you'll be able to set. So, here's the GUI Builder options tab in 6.1:

While here it is again, from a recent trunk build:

In other news. Read this great overview of the recent Manila Sun Tech Days by Randell, who was there to witness it all.

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
« July 2008 »
SunMonTueWedThuFriSat
  
4
5
6
11
12
13
14
17
26
30
  
       
Today