Previous Next        Current Page: NeXtMidas User's Guide / Third-Party Compatibility / NetBeans
FAQs   
Release Information   
Getting Help   
Basic Concepts   
Result Parameters   
XML Support   
Files   
System Operation   
Macros   
Applets and WebStart   
Graphics   
X-Midas Interoperability   
Third-Party Compatibility   
   - Apache   
   + Web Browsers   
   - Java   
   + WebStart   
   - Profilers   
   - NetBeans   
   - Eclipse   
   - JBuilder   
   - Intel Fortran Compiler   
   - Portland Group Compiler   
   - SWIG   
   - VNC   
Installation and Customization   
Running NeXtMidas Independently   
Glossary   


Using NetBeans with NeXtMidas

Note: This document was written using NetBeans 4.0. Please see the NeXtMidas Training for examples using NetBeans 5.0.

This section explains how the NetBeans GUI builder creates new panel definitions for existing macros. For an introduction on using JavaBeans to create panels in NeXtMidas, go to JavaBeans.

  1. Getting NetBeans
  2. Registering NeXtMidas Widgets
  3. Starting a Project in NetBeans
  4. Creating a New GUI Form
  5. Editing a GUI Panel
  6. How it Works
  7. How-To Tips
Note:
The following directions are for NetBeans IDE 4.0 running on Java 5.0 (1.5.0). Users with earlier versions should upgrade to benefit from the latest form editor enhancements.

Note:
The NetBeans use of "form" is equivalent to the Midas term "panel." Both words are used interchangably throughout this section.

Getting NetBeans

NetBeans is a "free and open source... integrated development environment for Java Software Developers" sponsored by Sun Microsystems. NetBeans can be downloaded, free of charge, in one of two ways:

  1. Stand-Alone Application - http://www.netbeans.org/
  2. Bundled with the Java Development Kit (JDK) - http://java.sun.com/

(Most users find that downloading and installing the bundled version is easiest.)

When the installation is complete, make a note of the command provided in the install window. This command starts NetBeans (on RedHat Linux, it may be /opt/netbeans-4.0/bin/netbeans).

Back to Top

Registering the NeXtMidas Widgets

NeXtMidas comes with two new Swing widgets that embed plots and other NeXtMidas displays in GUIs created with NetBeans. These steps register the NeXtMidas widgets:

  1. In NetBeans, select Tools-->Palette Manager
  2. Select "Add From JAR."
  3. Select the nxm-sys.jar JAR file (located in the $NMROOT/jars directory after NeXtMidas is built), and press "Finish."
  4. Select "Show Marked JavaBeans." Shift-select both "MidasControls" and "MidasDisplay," and then press "Next."
  5. Highlight "Swing" and press "Finish."
  6. To finish, press "Close" in Palette Manager .

Always repeat these registering instructions after installing a new NeXtMidas release to guarantee the most current NeXtMidas widgets.

Back to Top

Starting a Project in NetBeans

The first step in creating a GUI for an existing macro is establishing a NetBeans project for the macro's option tree:

  1. In NetBeans, select File-->New Project.
  2. Under "Categories," select "Standard" and "Java Project With Existing Sources." Press "Next."
  3. Press the "Browse" button next to "Source Packages Folder," and select the $NMROOT directory.
  4. For "Project Name," enter NeXtMidas_Project and press "Finish."
  5. Your project is now listed under the "Projects" tab on the left side of the NetBeans window.


Back to Top

Creating a New GUI Form

After a project is made for the appropriate option tree, you can create a new GUI form:

  1. The "Files" tab on the left side of the NetBeans window should list your project.
  2. Expand the project in the "Source Packages" section, and expand "nxm," "opt" (where "opt" is the name of your option tree), and then "mcr."
  3. Right-click on the "mcr" area, and select New-->File/Folder.
  4. Select "Java GUI Forms" and "JFrame Form," and press "Next."
  5. For "Class Name," enter the name of the macro the form will use (the name is lower-case and does not include a .mm extension on it), and press "Finish."


Back to Top

Editing a GUI Panel

This is a quick overview on using NetBeans to create NeXtMidas GUIs. For more details, please see the following:

Once the form is created, it can be edited. If the form is not opened, double click the icon under the projects tab on the left of the screen.

The form editor has two buttons: "Source" and "Design." The "Source" button brings up the Java source for the form (use this only if you are doing something more advanced in Java). The "Design" button brings up a graphical form editor.

On the right of the form editor, there are three windows: the Palette lists all available widgets (NeXtMidasControls and NeXtMidasDisplay widgets are at the bottom of the Swing palette); the Introspector shows the relation between the various widgets in the form; and the Properties list allows you to set/modify the widget properties.

There are three buttons at the top of the Properties window -- one for each property type:

  • Properties - General properties such as color, size, text, etc.
  • Events - Events
    (You probably won't need these)
  • Code - Code properties
    (The only property you are likely to modify is "Variable Name," which is also set by right-clicking on the widget and selecting "Rename...")

Usually, the first step is setting the form layout. Right-click on the form and select Set Layout. Choose a layout ("AbsoluteLayout" is usually a good one to start with).

To add a widget to hold a NeXtMidas plot, select the MidasDisplay from the Palette and click on the form where the display should go. Once the display is in position, select the display (click on it). In the Properties window, enter the ID of the NeXtMidas plot as the "Variable Name" (e.g., if the line in the macro defining the plot looks like plot/id=foo ..., then use foo as the "Variable Name").

The MidasControls widget is a special widget that displays the controls created by GCONTROL. By default, when a GUI form is used, NeXtMidas assumes all the controls are defined and does not attempt to "re-create" them. To avoid this (and allow GCONTROL to create the controls), place a MidasControls widget in the location where GCONTROL should place its controls and give it the variable name of "pane0"; GCONTROL then adds all of its controls on the MidasControls widget when the macro runs.

To test the form, save it, enter NeXtMidas, and try the following (substitute the name of your macro for geoplot and the name of your option tree for map):

    nM> path add map
    nM> bld geoplot.java mcr map
    nM> geoplot/jsetup



Back to Top

How it Works

When you run a macro with the /JSETUP switch, the PANEL command (inside the macro) is instructed to use the GUI panel created within NetBeans as the definition of the panel's layout.

As far as the macro is concerned, this is little different than using an alternate setup file for the panel (such as using /SETUP=2). The magic happens within PANEL which, rather than loading the setup based on a .mmp file, it uses the Java GUI created in NetBeans.

Java facilities allow PANEL to look inside the compiled GUI file and get a list of all the widgets used (and variable names). Then, PANEL provides the code necessary to register each as a control/display in NeXtMidas.

PANEL also provides the code necessary to allow most Swing widgets to act as NeXtMidas controls.

Back to Top

How-To Tips

    Make a Button Group

In a macro, it is possible to use a set of buttons that work together using the following:

gc button state "" "Run,Pause,Exit" 1

To have the same effect when using the GUI builder, create a ButtonGroup with the variable name "state." Next, create three buttons ("Run," "Pause," and "Exit"), and highlight the three buttons. Under "Properties," set "buttonGroup" to "state."

Note: Since "Variable Name" is the only text used while communicating with the macro, these buttons have user-friendly text and a helpful "toolTipText" set (unlike buttons created with GCONTROL).

Back to Top