< Previous | Next >

Lesson 1.3: Run the visual class

Now you are ready to run the Java application to preview its appearance. The workbench and visual editor make it very easy to quickly run your application, and you can repeat these steps at any time in your development to test the actual run-time appearance and behavior of the class.

The Java visual editor provides a Java Bean launcher that is capable of running classes with no main() method. When it runs the visual class, it launches the application in a separate virtual machine (VM). If you run a visual class as a Java application, the launcher attempts to execute the main() method in the class. For this tutorial, your application includes a main() method that invokes and shows the DirectoryApp JFrame, so you can run it as an application or as a Java bean.

To run the DirectoryApp.java file as a Java bean:

  1. Make sure that your DirectoryApp.java file is open in the Java visual editor.
  2. From the menu bar, click Run > Run As > Java Bean.

    Run As Java Bean context menu option

    Tip: The application opens on your desktop using the Swing look and feel that you have defined in your Visual Editor preferences (Window > Preferences > Java > Visual Editor). Alternatively, you can click Run > Run, and define the look and feel for the particular launch configuration for launching this Java bean. If you run this application as an application rather than a bean, it will also use the Windows look and feel because it is defined in the main() method. The screen shots used in this tutorial show the Windows look and feel.
My Company Directory running as Java bean

Lesson checkpoint

Because you have only designed the interface but have not programmed any data connection or event functionality, you cannot do anything with your application. However, you can see the basic layout and appearance as it will look to a user. You can try clicking some of the buttons, but you will notice that they do nothing. The File menu and Help menus, however, are already implemented for you. You can try them to see what they do, and you can inspect the Java code to see how they are implemented with actionPerformed events.

Lessons learned

This module introduced you to designing the interface for a rich client using the Java visual editor. Beyond designing the visual appearance of a client, however, there is much more that you need to do to actually make the client useful. You will typically need to include event behavior or other logic and, in this case, the binding of the visual elements to a data source of some sort.

In this module, you learned how to perform the following tasks:

  • Import a Java project using Project Interchange import
  • Add a JTable on a JScrollPane to your visual class
  • Use the GridBagLayout manager to visually lay out the table on the rich client
  • Run the application to see the actual appearance of the rich Java client

In the next module, Module 2: Bind visual components to the Web service, you will take the simple My Company Directory interface and turn it into a powerful rich client that accesses Web service methods for creating, retrieving, updating, and deleting employee records from a company directory.