TOC PREV NEXT INDEX



Creating a Swing Application


In our application, we have used two parts from the Swing pages on the palette, the JLabel and the JProgressBar. The application that we created, though, is still using the AWT's Frame and Panel to build the user interface. Since we want this application to be written using Swing's JFrame and JPanel, we have one more thing to do.

  1. At the top of the Composer window, press the 'View Code' button (the one with the eye on it). Notice that the class uses Frame and Panel to build the user interface.
  2. At the top of the Composer window, choose 'Thermostat' from the Part List.
  3. Check the 'Generate Swing Code' checkbox.
  4. Press the 'View Code' button again to refresh the code viewer window. Notice that the application now uses Swing's JFrame and JPanel to build the user interface.

Notice that the 'Default close action' field is enabled on the MainWindow property page when you select 'Generate Swing Code'. This option makes it easy to specify a default behavior when a JFrame is closed by the user.

  1. Select 'Dispose' from the 'Default close action' field. This tells the window to dispose of itself when the user requests that the window close. It saves us the work of creating a WindowListener which we previously did in Tutorial 1.

Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX