This example presents a tree view of some directories in the IFS.
/////////////////////////////////////////////////////////////////////////
//
// VIFSDirectory example. This program presents a tree view of
// some directories in the integrated file system.
//
// Command syntax:
// VIFSDirectoryExample system
//
// This source is an example of IBM Toolbox for Java "VIFSDirectory".
//
/////////////////////////////////////////////////////////////////////////
import com.ibm.as400.access.*;
import com.ibm.as400.vaccess.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class VIFSDirectoryExample
{
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: VIFSDirectoryExample 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 VIFSDirectory object which represents the root
// of the directory tree that we are going to show.
VIFSDirectory directory = new VIFSDirectory (system, "/QIBM/ProdData");
// Create a frame.
JFrame f = new JFrame ("VIFSDirectory example");
// Create an error dialog adapter. This will display
// any errors to the user.
ErrorDialogAdapter errorHandler = new ErrorDialogAdapter (f);
// Create a tree pane to present the directories hierarchically.
// Load the information from the system.
AS400TreePane treePane = new AS400TreePane (directory);
treePane.addErrorListener (errorHandler);
treePane.load ();
// When the frame closes, exit.
f.addWindowListener (new WindowAdapter () {
public void windowClosing (WindowEvent event)
{
System.exit (0);
}
});
// Layout the frame with the tree pane.
f.getContentPane ().setLayout (new BorderLayout ());
f.getContentPane ().add ("Center", treePane);
f.pack ();
f.show ();
}
catch (Exception e)
{
System.out.println ("Error: " + e.getMessage ());
System.exit (0);
}
}
}
Example: Using VPrinters
/////////////////////////////////////////////////////////////////////////
//
// VPrinters example. This program presents various network
// print resources with an explorer pane.
//
// Command syntax:
// VPrintersExample system
//
// This source is an example of IBM Toolbox for Java "VPrinters".
//
/////////////////////////////////////////////////////////////////////////
import com.ibm.as400.access.*;
import com.ibm.as400.vaccess.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class VPrintersExample
{
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: VPrintersExample 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 VPrinters object which represents the list
// of printers attached to the system.
VPrinters printers = new VPrinters (system);
// Create a frame.
JFrame f = new JFrame ("VPrinters example");
// Create an error dialog adapter. This will display
// any errors to the user.
ErrorDialogAdapter errorHandler = new ErrorDialogAdapter (f);
// Create an explorer pane to present the network print resources.
// Use load to load the information from the system.
AS400ExplorerPane explorerPane = new AS400ExplorerPane (printers);
explorerPane.addErrorListener (errorHandler);
explorerPane.load ();
// When the frame closes, exit.
f.addWindowListener (new WindowAdapter () {
public void windowClosing (WindowEvent event)
{
System.exit (0);
}
});
// Layout the frame with the explorer pane.
f.getContentPane ().setLayout (new BorderLayout ());
f.getContentPane ().add ("Center", explorerPane);
f.pack ();
f.show ();
}
catch (Exception e)
{
System.out.println ("Error: " + e.getMessage ());
System.exit (0);
}
}
}