Download NetBeans!

20090616 Tuesday June 16, 2009

Registering MigLayout in NetBeans IDE 6.7

I started creating a small module that integrates MigLayout into the IDE. That won't help Groovy developers at all, since the GUI Builder generates Java code (and that is unlikely to change). However, it will help Java developers who want to use MigLayout as their LayoutManager.

Already a couple of things are possible—when you create a Swing container in the Matisse GUI Builder, you can set MigLayout as your LayoutManager:

You'll find you have a new node for the layout you chose:

Then you'll also find the MigLayout JAR in the application's Libraries node, which indicates that it has been put on your classpath. In addition, the "initComponents" of a JFrame now has this content:

private void initComponents() {

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    getContentPane().setLayout(new net.miginfocom.swing.MigLayout());

    pack();
}

If you add a JPanel, the "initComponents" ends up like this:

 private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    getContentPane().setLayout(new net.miginfocom.swing.MigLayout());

    jPanel1.setLayout(new net.miginfocom.swing.MigLayout());
    getContentPane().add(jPanel1);

    pack();
}

You can tweak the Options window to not have the FQN generated. It's early days yet, so you can't add the MigLayout constraints yet (e.g., "wrap" and so on). Plus, the above are blue blocks, so you can't even add those constraints manually at this point. Also, the typical Matisse GUI Builder features such as align and resize and so on are not supported. All that's currently available is the registration of the MigLayout library and the ability to graphically add it to your project, together with code generation for setting the LayoutManager via the same graphical function.

The source code can be found here on Kenai:

http://kenai.com/projects/nbmiglayout/

If you have ideas about how the user should be able to graphically set MigLayout constraints, probably via drag-and-drop, I guess, feel free to join the project and share your ideas.

Jun 16 2009, 10:25:34 AM PDT Permalink

Trackback URL: http://blogs.sun.com/geertjan/entry/registering_miglayout_in_netbeans_ide
Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed