//************************************************************** // // Demonstrates using the AS400DetailsPane to display // AS/400 Spooled files for a given user // //************************************************************** // // To compile: javac AS400SpooledFilesDemo.java // //************************************************************** import java.awt.*; import java.applet.*; import javax.swing.*; import java.awt.event.*; import com.ibm.as400.access.AS400; import com.ibm.as400.vaccess.*; public class AS400SpooledFilesDemo extends JApplet { static JFrame frame = new JFrame(); JPanel viewerArea = new JPanel(); //Initialize the application public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { // viewer area viewerArea.add(createlistofspooledfilesArea()); // add component to ContentPane getContentPane().add(viewerArea, BorderLayout.CENTER); } //Start the applet public void start() { } //Stop the applet public void stop() { } //Destroy the applet public void destroy() { } //Get Applet information public String getAppletInfo() { return "Applet Information"; } //*************************************************** // Create the list of spooled files for this user //************************************************** protected AS400DetailsPane createlistofspooledfilesArea() { AS400 as400 = new AS400(); try { as400.connectService(as400.PRINT); } catch (com.ibm.as400.access.AS400SecurityException ase) {} catch (java.io.IOException ioe) {} // get the list of AS/400 spooled files for this user VPrinterOutput pout = new VPrinterOutput(as400); // get the user who signed on String currentUser = as400.getUserId(); // set the list to display only for this user try { pout.setUserFilter(currentUser); } catch (java.beans.PropertyVetoException pve) {} // Create an Error Dialog adapter to display any errors to the user ErrorDialogAdapter errorHandler = new ErrorDialogAdapter (frame); // Add the list of spooled files for this user to the AS400DetailsPane AS400DetailsPane adtls = new AS400DetailsPane(pout); // add the error listener to this component adtls.addErrorListener(errorHandler); // set the size of the AS400DetailsPane Dimension dsize = new Dimension(400, 400); adtls.setMaximumSize(dsize); adtls.setMinimumSize(dsize); // load the details pane adtls.load(); return adtls; } //**************************************************** //Main method //**************************************************** public static void main(String[] args) { AS400SpooledFilesDemo applet = new AS400SpooledFilesDemo (); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }}); frame.setTitle("iSeries AS400Details Pane - Spooled Files Viewer"); frame.getContentPane().add(applet, BorderLayout.CENTER); applet.init(); applet.start(); frame.setSize(250,200); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getSize().width)/ 2, (d.height - frame.getSize().height) / 2); frame.pack(); frame.setVisible(true); } //**************************************************** // static initializer for setting look & feel //**************************************************** static { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) {} } }