net.sf.freehost3270.gui
Class JTerminalScreen

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.sf.freehost3270.gui.JTerminalScreen
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, net.sf.freehost3270.client.RWTnAction

public class JTerminalScreen
extends javax.swing.JPanel
implements net.sf.freehost3270.client.RWTnAction, java.awt.event.KeyListener, java.awt.print.Printable

A SWING component that interactively renders terminal screen contents and handles user to terminal interaction.

The terminal is first rendered to a buffered image and then, whan a component repaint is requested this buffered image is painted on the given component's graphics context. In case if a default font size is changed, the JTerminalScreen adjusts it size in order to feed the grown terminal screen size.

Since:
0.1 RHPanel
See Also:
paintComponent(Graphics), setFont(Font), Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.awt.Color DEFAULT_BG_COLOR
          Default terminal background color.
static java.awt.Color DEFAULT_BOLD_COLOR
          Default font color used to render bold text.
static java.awt.Color DEFAULT_CURSOR_COLOR
          Default color used to render cursor pointer on the terminal screen.
static java.awt.Color DEFAULT_FG_COLOR
          Default terminal foreground color.
static java.awt.Color DEFAULT_FIELD_BG_COLOR
          Default input field background color.
static java.awt.Font DEFAULT_FONT
          Default font used to draw terminal.
static int DEFAULT_FONT_SIZE
          Default size of the screen font.
static int DEFAULT_HEIGHT
          The default height of the panel.
static int DEFAULT_WIDTH
          The default width of the panel.
static int MARGIN_LEFT
           
static int MARGIN_TOP
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface net.sf.freehost3270.client.RWTnAction
CONNECTION_ERROR, DISCONNECTED_BY_REMOTE_HOST, READY, X_WAIT
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JTerminalScreen()
          Construct a new GUI session with a terminalModel of 2, and a terminalType of 3279-E.
JTerminalScreen(int terminalModel)
          Construct a new GUI session with a 3279-E terminalType and the specified model where 2 <= terminalModel <= 5.
JTerminalScreen(int terminalModel, java.lang.String terminalType)
          Construct a new GUI session with the specified terminalModel and terminalType.
JTerminalScreen(java.lang.String terminalType)
          Construct a new GUI session with a model 2 (24x80) screen using either a 3278, 3279, or 3279-E terminalType.
 
Method Summary
 void beep()
           
 void broadcastMessage(java.lang.String msg)
           
 void clear()
           
 void connect(java.lang.String host, int port)
           
 void connect(java.lang.String host, int port, boolean encryption)
           
 void connect(java.lang.String host, int port, java.lang.String host3270, int port3270, boolean encryption)
          Opens a connection to the destination terminal server host.
 void cursorMove(int oldPos, int newPos)
           
 void disconnect()
           
 void enter()
           
 net.sf.freehost3270.client.RW3270 getRW3270()
           
 void incomingData()
           
 void keyPressed(java.awt.event.KeyEvent evt)
          Processess non-character keyboard events.
 void keyReleased(java.awt.event.KeyEvent evt)
          To satisfy interface declarations.
 void keyTyped(java.awt.event.KeyEvent evt)
           
 void mouseClicked(java.awt.event.MouseEvent e)
          Dispatches mouse event.
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void PA(int paKey)
           
protected  void paintChar(net.sf.freehost3270.client.RW3270Char c)
          Paints a char on the terminal panel.
protected  void paintComponent(java.awt.Graphics g)
          Paints backgoround buffered image on the given graphics context.
 void paintCursor(int pos)
           
 void paintStatus()
           
 void paintWindowMessage()
          Paints a message on the screen.
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
           
 void renderScreen()
          Renders a terminal screen on the buffered image graphics context.
 void run()
           
 void setBackgroundColor(java.awt.Color c)
           
 void setBoldColor(java.awt.Color c)
           
 void setCurrentPosition(int newPos)
           
 void setFont(java.awt.Font newFont)
          Sets the font used to draw the screen.
 void setForegroundColor(java.awt.Color c)
           
 void setStatus(java.lang.String statusMessage)
          Sets current status message and calls components repaint method to make the new status message visible.
 void setWindowMessage(int msg)
           
 void setWindowMessage(java.lang.String msg)
           
 void status(int status)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
The default width of the panel. Should be overriden upon panel initialization or font size change.

See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
The default height of the panel.

See Also:
DEFAULT_WIDTH, Constant Field Values

DEFAULT_FONT_SIZE

public static final int DEFAULT_FONT_SIZE
Default size of the screen font.

See Also:
Constant Field Values

DEFAULT_FONT

public static final java.awt.Font DEFAULT_FONT
Default font used to draw terminal.


DEFAULT_FG_COLOR

public static final java.awt.Color DEFAULT_FG_COLOR
Default terminal foreground color.


DEFAULT_BG_COLOR

public static final java.awt.Color DEFAULT_BG_COLOR
Default terminal background color.


DEFAULT_BOLD_COLOR

public static final java.awt.Color DEFAULT_BOLD_COLOR
Default font color used to render bold text.


DEFAULT_CURSOR_COLOR

public static final java.awt.Color DEFAULT_CURSOR_COLOR
Default color used to render cursor pointer on the terminal screen.


DEFAULT_FIELD_BG_COLOR

public static final java.awt.Color DEFAULT_FIELD_BG_COLOR
Default input field background color.


MARGIN_LEFT

public static final int MARGIN_LEFT
See Also:
Constant Field Values

MARGIN_TOP

public static final int MARGIN_TOP
See Also:
Constant Field Values
Constructor Detail

JTerminalScreen

public JTerminalScreen()
Construct a new GUI session with a terminalModel of 2, and a terminalType of 3279-E.


JTerminalScreen

public JTerminalScreen(int terminalModel,
                       java.lang.String terminalType)
Construct a new GUI session with the specified terminalModel and terminalType.

Parameters:
terminalModel -
terminalType -

JTerminalScreen

public JTerminalScreen(int terminalModel)
Construct a new GUI session with a 3279-E terminalType and the specified model where 2 <= terminalModel <= 5.

Parameters:
terminalModel -

JTerminalScreen

public JTerminalScreen(java.lang.String terminalType)
Construct a new GUI session with a model 2 (24x80) screen using either a 3278, 3279, or 3279-E terminalType.

Parameters:
terminalType -
Method Detail

beep

public void beep()
Specified by:
beep in interface net.sf.freehost3270.client.RWTnAction

broadcastMessage

public void broadcastMessage(java.lang.String msg)
Specified by:
broadcastMessage in interface net.sf.freehost3270.client.RWTnAction

connect

public void connect(java.lang.String host,
                    int port,
                    java.lang.String host3270,
                    int port3270,
                    boolean encryption)
Opens a connection to the destination terminal server host.

Parameters:
host -
port -
host3270 -
port3270 -
encryption - DOCUMENT ME!

connect

public void connect(java.lang.String host,
                    int port)
             throws java.io.IOException,
                    java.net.UnknownHostException
Throws:
java.io.IOException
java.net.UnknownHostException

connect

public void connect(java.lang.String host,
                    int port,
                    boolean encryption)
             throws java.io.IOException,
                    java.net.UnknownHostException
Throws:
java.io.IOException
java.net.UnknownHostException

cursorMove

public void cursorMove(int oldPos,
                       int newPos)
Specified by:
cursorMove in interface net.sf.freehost3270.client.RWTnAction

disconnect

public void disconnect()

getRW3270

public net.sf.freehost3270.client.RW3270 getRW3270()

incomingData

public void incomingData()
Specified by:
incomingData in interface net.sf.freehost3270.client.RWTnAction

PA

public void PA(int paKey)

enter

public void enter()

clear

public void clear()

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Processess non-character keyboard events. All control, meta, escape arrow key typed events are processed here.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
evt - DOCUMENT ME!

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
To satisfy interface declarations.

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
evt - DOCUMENT ME!

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Specified by:
keyTyped in interface java.awt.event.KeyListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Dispatches mouse event. In case if BUTTON1 is clicked, moves terminal cursor to the character, on which the mouse event occured.

Parameters:
e - DOCUMENT ME!

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)

paintCursor

public void paintCursor(int pos)

paintStatus

public void paintStatus()

paintWindowMessage

public void paintWindowMessage()
Paints a message on the screen.


renderScreen

public void renderScreen()
Renders a terminal screen on the buffered image graphics context.


run

public void run()

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)

setBoldColor

public void setBoldColor(java.awt.Color c)

setFont

public void setFont(java.awt.Font newFont)
Sets the font used to draw the screen. Based on the given font metrics, changes screen size in case if the background rendering buffer is not null.

Overrides:
setFont in class javax.swing.JComponent
Parameters:
newFont - the new font to use for rendering terminal screen.

setForegroundColor

public void setForegroundColor(java.awt.Color c)

setStatus

public void setStatus(java.lang.String statusMessage)
Sets current status message and calls components repaint method to make the new status message visible.

Parameters:
statusMessage - DOCUMENT ME!

setCurrentPosition

public void setCurrentPosition(int newPos)

setWindowMessage

public void setWindowMessage(int msg)

setWindowMessage

public void setWindowMessage(java.lang.String msg)

status

public void status(int status)
Specified by:
status in interface net.sf.freehost3270.client.RWTnAction

paintChar

protected void paintChar(net.sf.freehost3270.client.RW3270Char c)
Paints a char on the terminal panel.

Parameters:
c - DOCUMENT ME!

paintComponent

protected void paintComponent(java.awt.Graphics g)
Paints backgoround buffered image on the given graphics context.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - DOCUMENT ME!

print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException


Copyright © 2007. All Rights Reserved.