Note: Read the Code example disclaimer for important legal information.
///////////////////////////////////////////////////////////////////////// // // VMessageList example. This program presents a details // view of messages returned from a command call. // // Command syntax: // VMessageListExample system // // This source is an example of IBM Toolbox for Java "VMessageList". // ///////////////////////////////////////////////////////////////////////// import com.ibm.as400.access.*; import com.ibm.as400.vaccess.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class VMessageListExample { public static void main (String[] args) { // If a system was not specified, then display help text and // exit. if (args.length != 1) { System.out.println("Usage: VMessageListExample system"); 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 CommandCall object a run the command. CommandCall command = new CommandCall (system); command.run ("CRTLIB FRED"); // Create a VMessageList object with the messages // returned from the command call. VMessageList messageList = new VMessageList (command.getMessageList ()); // Create a frame. JFrame f = new JFrame ("VMessageList example"); // Create an error dialog adapter. This will display // any errors to the user. ErrorDialogAdapter errorHandler = new ErrorDialogAdapter (f); // Create a details pane to display the message list. // Use load to load the information. AS400DetailsPane detailsPane = new AS400DetailsPane (messageList); detailsPane.addErrorListener (errorHandler); detailsPane.load (); // When the frame closes, exit. f.addWindowListener (new WindowAdapter () { public void windowClosing (WindowEvent event) { System.exit (0); } }); // Layout the frame with the details pane. f.getContentPane ().setLayout (new BorderLayout ()); f.getContentPane ().add ("Center", detailsPane); f.pack (); f.show (); } catch (Exception e) { System.out.println ("Error: " + e.getMessage ()); System.exit (0); } } }