import netscape_beta.application.*; import netscape_beta.util.*; /** * A class used to transfer data to and from a widow. * When run as an Applet, applications may not touch the * disk due to security restrictions. This class solves * that problem by displaying an Input and Output window. * * @version 1.0 12 Dec 1996 * @author Andrew Miller */ public class AppletIOView { protected TextView m_appletInput = null; protected TextView m_appletOutput = null; protected TextField m_appletInputL = null; protected TextField m_appletOutputL = null; /** * Construct and display an AppletIOView in the provided * root window. * @param rootView View to display in. */ public AppletIOView(RootView rootView) { rootView.setColor(Color.lightGray); m_appletInputL = new TextField(0,0, 300, 20); m_appletInputL.setStringValue("Traversal Studio Input"); m_appletInputL.setBorder(null); m_appletInputL.setBackgroundColor(Color.lightGray); m_appletInputL.setSelectable(false); m_appletInputL.setEditable(false); m_appletOutputL = new TextField(320,0, 300, 20); m_appletOutputL.setStringValue("Traversal Studio Output"); m_appletOutputL.setBorder(null); m_appletOutputL.setBackgroundColor(Color.lightGray); m_appletOutputL.setSelectable(false); m_appletOutputL.setEditable(false); // two fields for transferring data m_appletInput = new TextView(0, 20, 300, 300); m_appletOutput = new TextView(320, 20, 300, 300); m_appletInput.setEditable(true); m_appletInput.setUseSingleFont(true); m_appletInput.setBackgroundColor(Color.white); m_appletInput.setSelectionColor(Color.cyan); m_appletOutput.setEditable(false); m_appletOutput.setSelectable(true); m_appletOutput.setUseSingleFont(true); m_appletOutput.setBackgroundColor(Color.white); m_appletOutput.setSelectionColor(Color.cyan); rootView.addSubview(m_appletInputL); rootView.addSubview(m_appletOutputL); rootView.addSubview(m_appletInput); rootView.addSubview(m_appletOutput); } /** * Remove an AppletIOView from it's rootview. */ public void removeFromSuperView() { if(m_appletInput != null) m_appletInput.removeFromSuperview(); if(m_appletOutput != null) m_appletOutput.removeFromSuperview(); if(m_appletInputL != null) m_appletInputL.removeFromSuperview(); if(m_appletOutputL != null) m_appletOutputL.removeFromSuperview(); } /** * Retrieve the text the input window in the form of a string * @return Text string containing user input */ public String getAppletInput() { return m_appletInput.string(); } /** * Set the text output window to the specified string. * @param Text string containing output */ public void setAppletOutput(String output) { m_appletOutput.setString(output); } }