Note: Read the Code example disclaimer for important legal information.
///////////////////////////////////////////////////////////////////////// // // RecordListFormPane example. This program presents a form that contains // the contents of a file on the server. // // Command syntax: // RecordListFormPaneExample system fileName // // This source is an example of IBM Toolbox for Java "RecordListFormPane". // ///////////////////////////////////////////////////////////////////////// import com.ibm.as400.access.*; import com.ibm.as400.vaccess.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class RecordListFormPaneExample { public static void main (String[] args) { // If a system and fileName was not specified, then display // help text and exit. if (args.length != 2) { System.out.println("Usage: RecordListFormPaneExample system fileName"); return; } try { // Create an AS400 object. The system name was passed // as the first command line argument. AS400 system = new AS400 (args[0]); // Create a frame. JFrame f = new JFrame ("RecordListFormPane example"); // Create an error dialog adapter. This will display // any errors to the user. ErrorDialogAdapter errorHandler = new ErrorDialogAdapter (f); // Create a record list form pane to present the contents // of the database. Note we create the form pane, add // the error listener, then set the system and file name. // Creating the form pane and setting its parameters // can be done in one step as follows: // RecordListFormPane formPane = new RecordListFormPane (system, args[1]); // The potential problem is there is no error listener yet // so if the file name is not correct, there is no place // to display the error. RecordListFormPane formPane = new RecordListFormPane(); formPane.addErrorListener (errorHandler); formPane.setSystem(system); formPane.setFileName(args[1]); // Retrieve the information from the system. formPane.load (); // When the frame closes, exit. f.addWindowListener (new WindowAdapter () { public void windowClosing (WindowEvent event) { System.exit (0); } }); // Layout the frame with the form pane. f.getContentPane ().setLayout (new BorderLayout ()); f.getContentPane ().add ("Center", formPane); f.pack (); f.show (); } catch (Exception e) { System.out.println ("Error: " + e.getMessage ()); System.exit (0); } } }