ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/vcmd.htm

112 lines
6.0 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="Command Call" />
<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="vcmd" />
<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>Command Call</title>
</head>
<body id="vcmd"><a name="vcmd"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Command Call</h1>
<div><p></p>
<div class="section"><p>The command call vaccess (GUI) components allow a Java™ program
to present a button or menu item that calls a non-interactive server command.</p>
</div>
<div class="section"><p>A <a href="javadoc/com/ibm/as400/vaccess/CommandCallButton.html#NAVBAR_TOP"> CommandCallButton</a> object represents a button that calls
a server command when pressed. The CommandCallButton class extends the Java Foundation
Classes (JFC) JButton class so that all buttons have a consistent appearance
and behavior.</p>
</div>
<div class="section"><p>Similarly, a <a href="javadoc/com/ibm/as400/vaccess/CommandCallMenuItem.html#NAVBAR_TOP"> CommandCallMenuItem</a> object represents a menu item that
calls a server command when selected. The CommandCallMenuItem class extends
the JFC JMenuItem class so that all menu items also have a consistent appearance
and behavior.</p>
</div>
<div class="section"><p>To use a command call graphical user interface component, set
both the system and command properties. These properties can be set using
a constructor or through the setSystem() and setCommand() methods.</p>
</div>
<div class="section"><p><span class="synph" id="vcmd__vcmdex1"><a name="vcmd__vcmdex1"><!-- --></a><span class="kwd"></span></span>The following example creates
a CommandCallButton. At run time, when the button is pressed, it creates a
library called "FRED":</p>
</div>
<div class="section"><div class="p"><pre> // Create the CommandCallButton
// object. Assume that "system" is
// an AS400 object created and
// initialized elsewhere. The button
// text says "Press Me", and there is
// no icon.
CommandCallButton button = new CommandCallButton ("Press Me", null, system);
// Set the command that the button will run.
button.setCommand ("CRTLIB FRED");
// Add the button to a frame. Assume
// that "frame" is a JFrame created
// elsewhere.
frame.getContentPane ().add (button);</pre>
</div>
</div>
<div class="section"><p>When a server command runs, it may return zero or more server
messages. To detect when the server command runs, add an <a href="javadoc/com/ibm/as400/access/ActionCompletedListener.html#NAVBAR_TOP"> ActionCompletedListener</a> to the button or menu item using
the addActionCompletedListener() method. When the command runs, it fires an <a href="javadoc/com/ibm/as400/access/ActionCompletedEvent.html#NAVBAR_TOP"> ActionCompletedEvent</a> to all such listeners. A listener
can use the getMessageList() method to retrieve any server messages that the
command generated.</p>
</div>
<div class="section"><p><span class="synph" id="vcmd__vcmdex2"><a name="vcmd__vcmdex2"><!-- --></a><span class="kwd"></span></span>This example adds an ActionCompletedListener
that processes all server messages that the command generated:</p>
</div>
<div class="section"><div class="p"><pre> // Add an ActionCompletedListener that
// is implemented using an anonymous
// inner class. This is a convenient
// way to specify simple event
// listeners.
button.addActionCompletedListener (new ActionCompletedListener ()
{
public void actionCompleted (ActionCompletedEvent event)
{
// Cast the source of the event to a
// CommandCallButton.
CommandCallButton sourceButton = (CommandCallButton) event.getSource ();
// Get the list of server messages
// that the command generated.
AS400Message[] messageList = sourceButton.getMessageList ();
// ... Process the message list.
}
});</pre>
<strong>Examples</strong></div>
</div>
<div class="section"><p>This example shows how to use a <a href="commandcallmenuitemexample.htm#commandcallmenuitemexample">CommandCallMenuItem</a> in
an application.</p>
</div>
<div class="section"><p>Figure 1 shows the CommandCall graphical user interface component:</p>
</div>
<div class="section"><p><strong>Figure 1: CommandCall GUI component</strong></p>
</div>
<div class="section"><p><img src="rzahh080.gif" alt="CommandCall GUI component" /></p>
</div>
</div>
</body>
</html>