public class communicationsWindow extends Object
Modifier and Type | Field and Description |
---|---|
private TextArea |
bottomWindow
The bottomWindow TextArea is used to hold information
being prepared for transmission.
|
private Button |
closeButton
The closeButton Button can be used to
close the connection when it fails
to close normally.
|
protected int |
colsCurrent
The number of columns in the TextArea objects
currently.
|
protected int |
colsLarger
The number of columns in the TextArea objects if
the window is made wider.
|
protected int |
colsSmaller
The number of columns in the TextArea objects if
the window is made narrower.
|
private int |
debugLevel
Determines amount of diagnostic material to be
printed.
|
protected int |
heightCurrent
This is the height in pixels returned by the
TextArea.getMinimumSize method for a
TextArea block rowsCurrent rows in height.
|
protected int |
heightLarger
This is the height in pixels returned by the
TextArea.getMinimumSize method for a
TextArea block rowsLarger rows in height.
|
protected int |
heightSmaller
This is the height in pixels returned by the
TextArea.getMinimumSize method for a
TextArea block rowsSmaller rows in height.
|
private BufferedReader |
in |
protected boolean |
initialized
Set to true when the objects in the window
have been initialized.
|
private FlowLayout |
layout |
private BufferedWriter |
logBuffer |
private FileWriter |
logFile |
private boolean |
logFileActive
Determines whether messages are written to the log file.
|
private String |
logFileName |
private PrintWriter |
logWriter
Used for writing the communicated text to a log file.
|
private Frame |
myFrame
Object for the frame in which the application
is displayed.
|
private Panel |
myPanel
The myPanel panel provides a place to attach
key listeners.
|
private PrintWriter |
pw |
protected int |
rowsCurrent |
protected int |
rowsLarger |
protected int |
rowsSmaller
Used to determine the number of rows that should
be in the TextArea objects when the height of
TextArea objects is made slightly smaller.
|
private Button |
sendButton
The sendButton Button object causes the material in the
lower window to be sent over the communication line.
|
private Socket |
sock |
private InputStreamReader |
streamReader |
private TextArea |
topWindow
The topWindow TextArea holds the information sent from
the other end of the connection.
|
protected int |
widthCurrent
The width of the TextArea objects in pixels when
they are colsCurrent columns wide.
|
protected int |
widthLarger
The width of the TextArea objects in pixels when
they are colsLarger columns wide.
|
protected int |
widthSmaller
The width of the TextArea objects in pixels when
they are colsSmaller columns wide.
|
private String |
windowName |
private static int |
windowNumber |
Constructor and Description |
---|
communicationsWindow(String name) |
Modifier and Type | Method and Description |
---|---|
protected void |
addMessage(String display)
This method generates a message and adds it to the
log and the Sys.output character stream.
|
int |
getDebugLevel() |
protected void |
processKey(KeyEvent e)
This function is called whenever a key is pressed.
|
protected void |
sendMessage()
This method is called when the Send button is depressed
on the form
or the user depresses the Return key on the keyboard.
|
void |
setDebugLevel(int level)
This method is used to control the amount of diagnostic
messages generated.
|
void |
start(Socket inputSock)
This is the main method for creating the communications
window and setting up the communications stream.
|
protected void |
windowResizer()
This method is called when the window is resized.
|
private int debugLevel
private static int windowNumber
private FlowLayout layout
private PrintWriter pw
private BufferedReader in
private InputStreamReader streamReader
private String logFileName
private boolean logFileActive
private FileWriter logFile
private BufferedWriter logBuffer
private PrintWriter logWriter
protected int colsSmaller
protected int colsCurrent
protected int colsLarger
protected int widthSmaller
protected int widthCurrent
protected int widthLarger
protected int rowsSmaller
The TextArea.getMinimumSize method is applied to an object eight rows taller than the topWindow object. This allows room for bottomWindow and the buttons.
protected int rowsCurrent
protected int rowsLarger
protected int heightSmaller
protected int heightCurrent
protected int heightLarger
protected boolean initialized
Some events related to window movement and resizing may be generated before the objects fully initialized. These should not be responded to as the sizes and locations have not yet been set.
private TextArea bottomWindow
private TextArea topWindow
private Button sendButton
The data is also sent when the user depresses the Return key on the keyboard. This button on the form may be removed at a later date.
private Button closeButton
private Frame myFrame
The menu bar is attached to the frame.
private Panel myPanel
It appears that a Panel is a container, but a Frame isn't. Since listeners must be attached to containers, it was necessary to create a panel within the frame.
After the object is created, a listener is created with an anonymous inner class to react to changes in the size of the panel.
private String windowName
public communicationsWindow(String name)
protected void windowResizer()
It examines the width and height of the windows to determine whether the TextArea objects should have their height and width changed.
protected void addMessage(String display)
protected void processKey(KeyEvent e)
If the Delete or Backspace key is depressed, the last character in the bottomWindow textArea is removed.
If the Return key is depressed, the contents of bottomWindow are sent to the remote system and contents of bottomWindow are erased.
protected void sendMessage()
public void setDebugLevel(int level)
A value of 0 means no messages are to be printed. Higher values generate larger amounts of messages.
public int getDebugLevel()