156 lines
5.8 KiB
HTML
156 lines
5.8 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Example: Using IFSTextFileDocument" />
|
|
<meta name="abstract" content="" />
|
|
<meta name="description" content="" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="ifstextfiledocumentexample" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Example: Using IFSTextFileDocument</title>
|
|
</head>
|
|
<body id="ifstextfiledocumentexample"><a name="ifstextfiledocumentexample"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Using IFSTextFileDocument</h1>
|
|
<div><p></p>
|
|
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
|
example disclaimer</a> for important legal information.</div>
|
|
<pre>/////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// IFS text file document example. This program demonstrates how to
|
|
// use a document that is associated with a text file in the AS/400
|
|
// integrated file system.
|
|
//
|
|
// Command syntax:
|
|
// IFSTextFileDocumentExample system path
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
import com.ibm.as400.access.*;
|
|
import com.ibm.as400.vaccess.*;
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.awt.event.*;
|
|
|
|
public class IFSTextFileDocumentExample
|
|
{
|
|
|
|
|
|
|
|
private static IFSTextFileDocument document;
|
|
private static JTextPane text;
|
|
|
|
|
|
|
|
public static void main (String[] args)
|
|
{
|
|
// If a system or path was not specified, then display
|
|
// help text and exit.
|
|
if (args.length != 2)
|
|
{
|
|
System.out.println("Usage: IFSTextFileDocumentExample system path");
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
// Create two frames.
|
|
JFrame f = new JFrame ("IFS text file document example");
|
|
|
|
// Create an error dialog adapter. This will display
|
|
// any errors to the user.
|
|
ErrorDialogAdapter errorHandler = new ErrorDialogAdapter (f);
|
|
|
|
// Create a working cursor adapter. This will adjust
|
|
// the cursor whenever the text file is read or written.
|
|
WorkingCursorAdapter cursorAdapter = new WorkingCursorAdapter (f);
|
|
|
|
// Create an AS400 object. The system name was passed
|
|
// as the first command line argument.
|
|
AS400 system = new AS400 (args[0]);
|
|
|
|
// Create and load the IFS text file document.
|
|
document = new IFSTextFileDocument (system, args[1]);
|
|
document.addErrorListener (errorHandler);
|
|
document.addWorkingListener (cursorAdapter);
|
|
document.load ();
|
|
|
|
// Create the text pane used to present the document.
|
|
text = new JTextPane (document);
|
|
text.setSize (new Dimension (500, 500));
|
|
|
|
// Set up a scroll pane to use with the text pane.
|
|
JScrollPane scroll = new JScrollPane (text);
|
|
scroll.setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
|
scroll.setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
|
|
|
// Create a menu bar with a single menu.
|
|
MenuBar menuBar = new MenuBar ();
|
|
Menu menu = new Menu ("File");
|
|
menuBar.add (menu);
|
|
|
|
// Add menu items to load and save.
|
|
MenuItem load = new MenuItem ("Load");
|
|
load.addActionListener (new ActionListener ()
|
|
{
|
|
public void actionPerformed (ActionEvent event)
|
|
{
|
|
document.load ();
|
|
}
|
|
});
|
|
menu.add (load);
|
|
|
|
MenuItem save = new MenuItem ("Save");
|
|
save.addActionListener (new ActionListener ()
|
|
{
|
|
public void actionPerformed (ActionEvent event)
|
|
{
|
|
document.save ();
|
|
}
|
|
});
|
|
menu.add (save);
|
|
|
|
// When the the frame closes, exit.
|
|
f.addWindowListener (new WindowAdapter () {
|
|
public void windowClosing (WindowEvent event)
|
|
{
|
|
System.exit (0);
|
|
}
|
|
});
|
|
|
|
// Layout the frame.
|
|
f.getContentPane ().setLayout (new BorderLayout ());
|
|
f.getContentPane ().add ("Center", scroll);
|
|
f.setMenuBar (menuBar);
|
|
f.pack ();
|
|
f.show ();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
System.out.println ("Error: " + e.getMessage ());
|
|
System.exit (0);
|
|
}
|
|
}
|
|
|
|
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |