The CustomTerminal bean provides a customizable emulator GUI, where screens can be customized using the Screen Customizer Studio. The CustomTerminal bean is only available if you have installed Screen Customizer and requires the Host On-Demand Toolkit to compile and run. See Building Host Access Beans Applets for more information on the packages to import. For more information on how to access customized screens (designed with Screen Customizer) with this sample, see Publishing Customized Screens.
Only KeyPad, KeyRemap and FileTransfer beans can be wired to this bean.
The following explains each statement or group of statements that are used in this sample program:
import com.ibm.hi.customizer.beans.*; // Get the Screen Customizer Beans import com.ibm.eNetwork.beans.HOD.*; // Get the Host Access Beans import com.ibm.eNetwork.ECL.ECLSession; // Get the ECLSession constants import com.ibm.eNetwork.HOD.common.*; // Get the Environment class import java.applet.*; // Get the Applet class import java.awt.*; // Get Frame and Color classes import java.util.*; // Get the Properties class
public class CustomTermTest extends Applet {
CustomTerminal myTerm; KeyPad myPad;
public void init() { super.init(); setLayout(new BorderLayout());
Environment env = new Environment(this);
try { Properties p = new Properties(); // Add some CustomTerminal bean properties
In Host On-Demand, we can set our host name to a valid TCP/IP host and start
the host connection. In this next statement, you would replace "myHost" with the
name of your telnet server.
In Personal Communications, the Session configuration information is contained
in workstation profile (.WS file). The name of the .WS file would replace
"myHost" in the following statement.
p.put(Session.HOST, "myHost"); p.put(Session.SESSION_TYPE, ECLSession.SESSION_TYPE_3270_STR); p.put(Session.CODE_PAGE, ECLSession.SESSION_CODE_PAGE_DEFAULT);
// Add some KeyPad bean properties p.put(KeyPad.SHAPE, KeyPad.S2X11);
myTerm = new CustomTerminal(p); // Build a CustomTerminal bean myPad = new KeyPad(p); // Build a KeyPad bean
myPad.addSendKeyListener(myTerm);
myTerm.addPropertyChangeListener(myPad);
add("Center", myTerm); add("South", myPad); System.out.println("Starting communications to myhost..."); myTerm.startCommunication();
validate(); } catch (Exception e) { e.printStackTrace(); } } }
Here is the whole program without the editorial comments:
import com.ibm.hi.customizer.beans.*; // Get the Screen Customizer Beans import com.ibm.eNetwork.beans.HOD.*; // Get the Host Access Beans import com.ibm.eNetwork.ECL.ECLSession; // Get the ECLSession constants import com.ibm.eNetwork.HOD.common.*; // Get the Environment class import java.applet.*; // Get Applet class import java.awt.*; // Get the Color and Frame classes import java.util.*; // Get Properties public class CustomTermTest extends Applet { CustomTerminal myTerm; KeyPad myPad;
public void init() { super.init(); // Call init on the super class setLayout(new BorderLayout());
// Set up HOD Environment with applet instance Environment env = new Environment(this); // These constructors also accept a properties object that // contains all the configuration data for each bean. // Customization can also be done at runtime through each // bean's customizer class. try { Properties p = new Properties(); // Instead of "myHost" you would put the name of your telnet server p.put(Session.HOST, "myHost"); p.put(Session.SESSION_TYPE, ECLSession.SESSION_TYPE_3270_STR); p.put(Session.CODE_PAGE, ECLSession.SESSION_CODE_PAGE_DEFAULT); // Add some KeyPad bean properties p.put(KeyPad.SHAPE, KeyPad.S2X11); myTerm = new CustomTerminal(p); // Build a CustomTerminal bean myPad = new KeyPad(p); // Build a KeyPad bean // Add the CustomTerminal bean as a SendKeyEvent listener on the KeyPad bean. // This means that any SendKeyEvents generated by the KeyPad bean will // be sent to the CustomTerminal bean's SendKey method for processing. A // SendKeyEvent is generated by the keypad whenever the user clicks on // a KeyPad button. myPad.addSendKeyListener(myTerm); // Add KeyPad as PropertyChangeListener on CustomTerminal. This notifies the // KeyPad bean of changes to CustomTerminal properties. KeyPad will change // the buttons displayed based on the terminal session type and codepage. myTerm.addPropertyChangeListener(myPad); add("Center", myTerm); add("South", myPad); System.out.println("Starting communications to myhost..."); myTerm.startCommunication(); validate(); } catch (Exception e) { e.printStackTrace(); } } // end init method } // end CustomTermTest class
Finally, here's a simple HTML file to run the applet you created:
<HTML> <HEAD> <TITLE>First Host Access Beans Applet</TITLE> </HEAD> <BODY> <APPLET CODE="CustomTermTest.class" WIDTH=600 HEIGHT=700> </APPLET> </BODY> </HTML>
To run CustomTermTest, save the sample program in a file called CustomTermTest.java and compile it. Ensure that your CLASSPATH environment variable is set correctly (see Building Host Access Beans Applets). You can run the CustomTermTest applet by executing the following command:
appletviewer CustomTermTest.html
[ Top of Page | Previous Page | Next Page | Table of Contents ]