GUIFramework (GFW) is the basic module for developing Swing GUIs at SLAC.

Developer's Guide

This guide describes in detail how to use the GFW in a Swing application. In general, you create your own Swing components (either programmatically, or with a GUI builder) and add them to the appropriate GFW frame.

Overview

We recommend the following steps:

  1. #Check out GFW from CVS into Eclipse.
  2. #Read and run the example code.
  3. #Create custom components for the desired GFW frame
  4. #Customize GFW.
  5. #Test the application.
  6. Optional features.
  7. #Tips.

Check out GFW from CVS into Eclipse

GFW is located in $CVSROOT/physics/GUIFramework

Read and run the example code

An example can be found in the class edu.stanford.slac.gfw.example.GfwExample

When running the example, please observe:

Create custom components for the desired GFW frame

For a quick development (e.g. GUI mock ups), we recommend the Netbeans GUI Builder (sometimes called "Matisse").
A nice overview of all Swing components is at http://java.sun.com/docs/books/tutorial/ui/features/components.html

Using GFW to build a GUI Application

  1. If you have not already done so, create a Java Project (File -> New -> Java Project). TODO: Add naming guidelines.
  2. Add GFW and SwingUtil to your Eclipse project buildpath. You can do this either by including the GUIFramework and SwingUtil projects to your workspace, and then importing them into your new project (File -> Import -> Project from Workspace), or File -> Import... -> CVS -> Projects from CVS, or by including their jar files from the production distribution location. E.g. GUIFramework.jar is in /usr/local/lcls/physics/GUIFramework/jar/GUIFramework.jar.
  3. Instantiate the custom components. For instance, if you have not yet created the main class, now you would do so. Note, that this class is likely to be in a different package to the User Interface package if you are separating UI components from application code.
  4. Create a BasicFrame or a ModelFrame instance of the GFW, e.g
    final BasicFrame myFrame = new BasicFrame("My Frame"); 
    
    or
    final ModelFrame myFrame = new ModelFrame("My Model Frame"); 
    
  5. Add custom components to various areas of the GFW frame, such as
  6. Set application version
    BasicFrame myFrame = ...; // see above
    JLabel appVersionLabel = myFrame.getBasicPanel().getStatusPanel().getAppVersionLabel();
    appVersionLabel.setText("my version"); //run in the GUI thread, of before displaying the frame
    
  7. #Add event listeners to the appropriate widgets
  8. Display the GFW frame
    SwingUtilities.invokeLater(new Runnable() {
    	public void run() {
    		myFrame.setVisible(true);
    	}
    });
    

Add event listeners to the appropriate widgets

Below we describe the recommended way, but nothing prevents you from using any other technique.

First define the methods which will be called by ??? in response to an event on your components. In this example we define the methods that will be called in response to changing the active tab of the tab panel (topTabChanged) and define the method that will be called in response to some component being activated. Note that the names of these methods is up to you. You will connect the method to the event later.

Set web help URL

If you want to provide help via the default GFW way, set the URL of your help website.

BasicFrameListener myFrameListener = ...;
myFrameListener.setHelpUrl("http://www.google.com");

Test the application

Optional features

Info Text Pane

Located in the status panel, the info text pane can be used to display some info beyond messaging.

JTextPane infoTextPane = bf.getBasicPanel().getStatusPanel().getInfoTextPane();
infoTextPane.setText("my info"); //run in the GUI thread, of before displaying the frame

Progress Bar

Located in the status panel, the progress bar could be used to display the progress of your program.

SwingUtil

Tips