com.sshtools.terminal.swing
Class SwingTerminalPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.sshtools.terminal.swing.SwingTerminalPanel
All Implemented Interfaces:
java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.print.Printable, java.io.Serializable, VDUDisplay

public class SwingTerminalPanel
extends javax.swing.JComponent
implements VDUDisplay, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.print.Printable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int COLOR_BOLD
           
static int COLOR_INVERT
           
protected  VDUScrollBar scrollBar
           
 
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 com.sshtools.terminal.VDUDisplay
CURSOR_BLINK, CURSOR_BLOCK, CURSOR_LINE, RESIZE_FONT, RESIZE_NONE, RESIZE_SCREEN
 
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
SwingTerminalPanel()
           
 
Method Summary
 void addFocusListener(java.awt.event.FocusListener listener)
           
 void addKeyListener(java.awt.event.KeyListener listener)
           
 void addMouseListener(java.awt.event.MouseListener listener)
           
 void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
           
 void addNotify()
           
 void clearSelection()
           
 void focusTerminal()
          Terminal component requests focus
 java.awt.Color[] getColorSet()
           
 java.awt.Component getComponent()
          Get the component.
 int getCursorStyle()
          Get the cursor style.
 java.awt.Insets getInsets()
           
 int getMouseWheelIncrement()
           
 java.awt.Dimension getPreferredSize()
           
 int getResizeStrategy()
          Return the current resize strategy.
 VDUScrollBar getScrollBar()
          Get the scrollbar (if any) that this display is using
 java.lang.String getSelection()
          Return the currently selected text from the terminal.
 java.awt.Dimension getSize()
           
 java.awt.Font getTerminalFont()
          Get the terminal font
 VDUBuffer getVDUBuffer()
          Get the current buffer
 void init(VDUBuffer buffer)
          Initialise the display.
 boolean isAntialias()
           
 boolean isCursorBlink()
          Get whether the cursor shoud blink or not.
 boolean isReverseVideo()
          Get whether reverse video is currently enabled
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
static void main(java.lang.String[] args)
           
protected  double max(double f1, double f2)
           
protected  double min(double f1, double f2)
           
 void mouseClicked(java.awt.event.MouseEvent evt)
           
 void mouseDragged(java.awt.event.MouseEvent evt)
           
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 java.awt.Point mouseGetPos(java.awt.Point evtpt)
           
 void mouseMoved(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
           
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void paintComponent(java.awt.Graphics g1)
           
 void print(java.awt.Graphics g)
           
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
           
 void processEvent(java.awt.AWTEvent evt)
           
 void processFocusEvent(java.awt.event.FocusEvent evt)
           
 void processKeyEvent(java.awt.event.KeyEvent evt)
           
 void processMouseEvent(java.awt.event.MouseEvent evt)
           
 void processMouseMotionEvent(java.awt.event.MouseEvent evt)
           
 void recalculateFontAndDisplaySize()
          Recalculate the font size and the size of the display.
 void redisplay()
          Redisplay everything, including resizing the display if necessary.
 void redraw()
          Implement to redraw the terminal screen from the current buffer
protected  void redraw(java.awt.Graphics g1)
           
 void refresh()
           
 void removeFocusListener(java.awt.event.FocusListener listener)
           
 void removeKeyListener(java.awt.event.KeyListener listener)
           
 void removeMouseListener(java.awt.event.MouseListener listener)
           
 void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
           
 void setAntialias(boolean antialias)
           
 void setBorder(int thickness, boolean raised)
           
 void setBounds(int x, int y, int w, int h)
           
 void setColorPrinting(boolean colorPrint)
          Set whether colors should be printed.
 void setColorSet(java.awt.Color[] colorset)
           
 void setCursorBlink(boolean blink)
          Set whether the cursor shoud blink or not.
 void setCursorColors(java.awt.Color fg, java.awt.Color bg)
          Set the cursor colors.
 void setCursorStyle(int cursorStyle)
          Set the cursor style.
 void setDefaultBackground(java.awt.Color color)
          Set the default background color of the terminal
 void setDefaultForeground(java.awt.Color color)
          Set the default background color of the terminal
 void setFont(java.awt.Font font)
           
 void setMouseWheelIncrement(int mouseWheelIncrement)
          Set the mouse wheel increment in lines.
 void setResizeStrategy(int strategy)
          Set the resize strategy.
 void setReverseVideo(boolean reverseVideo)
          Set whether reverse video is enabled
 void setScrollBar(VDUScrollBar scrollBar)
          Set the scrollbar (or null for no scrollbar) that this display should use.
 void setTerminalFont(java.awt.Font font)
          Set the default font
 void setVDUBuffer(VDUBuffer buffer)
          Set the current buffer
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, 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

COLOR_BOLD

public static final int COLOR_BOLD
See Also:
Constant Field Values

COLOR_INVERT

public static final int COLOR_INVERT
See Also:
Constant Field Values

scrollBar

protected VDUScrollBar scrollBar
Constructor Detail

SwingTerminalPanel

public SwingTerminalPanel()
Method Detail

init

public void init(VDUBuffer buffer)
Description copied from interface: VDUDisplay
Initialise the display.

Specified by:
init in interface VDUDisplay
Parameters:
buffer - buffer

max

protected double max(double f1,
                     double f2)

min

protected double min(double f1,
                     double f2)

setAntialias

public void setAntialias(boolean antialias)

isAntialias

public boolean isAntialias()

setVDUBuffer

public void setVDUBuffer(VDUBuffer buffer)
Description copied from interface: VDUDisplay
Set the current buffer

Specified by:
setVDUBuffer in interface VDUDisplay
Parameters:
buffer - buffer

getVDUBuffer

public VDUBuffer getVDUBuffer()
Description copied from interface: VDUDisplay
Get the current buffer

Specified by:
getVDUBuffer in interface VDUDisplay
Returns:
buffer

setColorSet

public void setColorSet(java.awt.Color[] colorset)

getColorSet

public java.awt.Color[] getColorSet()

setFont

public void setFont(java.awt.Font font)

setResizeStrategy

public void setResizeStrategy(int strategy)
Description copied from interface: VDUDisplay

Set the resize strategy. Can be one of :-

Specified by:
setResizeStrategy in interface VDUDisplay
Parameters:
strategy - resize strategy

setBorder

public void setBorder(int thickness,
                      boolean raised)

setScrollBar

public void setScrollBar(VDUScrollBar scrollBar)
Description copied from interface: VDUDisplay
Set the scrollbar (or null for no scrollbar) that this display should use.

Specified by:
setScrollBar in interface VDUDisplay
Parameters:
scrollBar - scrollbar

redraw

public void redraw()
Description copied from interface: VDUDisplay
Implement to redraw the terminal screen from the current buffer

Specified by:
redraw in interface VDUDisplay

redraw

protected void redraw(java.awt.Graphics g1)

main

public static void main(java.lang.String[] args)

paintComponent

public void paintComponent(java.awt.Graphics g1)

setColorPrinting

public void setColorPrinting(boolean colorPrint)
Description copied from interface: VDUDisplay
Set whether colors should be printed.

Specified by:
setColorPrinting in interface VDUDisplay
Parameters:
colorPrint - color printing

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

print

public void print(java.awt.Graphics g)

mouseGetPos

public java.awt.Point mouseGetPos(java.awt.Point evtpt)

setCursorColors

public void setCursorColors(java.awt.Color fg,
                            java.awt.Color bg)
Description copied from interface: VDUDisplay
Set the cursor colors. null means default to text color.

Specified by:
setCursorColors in interface VDUDisplay
Parameters:
fg - cursor foreground
bg - cursor background

redisplay

public void redisplay()
Description copied from interface: VDUDisplay
Redisplay everything, including resizing the display if necessary.

Specified by:
redisplay in interface VDUDisplay

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)

recalculateFontAndDisplaySize

public void recalculateFontAndDisplaySize()
Description copied from interface: VDUDisplay
Recalculate the font size and the size of the display. Invoked when a screen resize event occurs.

Specified by:
recalculateFontAndDisplaySize in interface VDUDisplay

refresh

public void refresh()

getSize

public java.awt.Dimension getSize()

getPreferredSize

public java.awt.Dimension getPreferredSize()

getInsets

public java.awt.Insets getInsets()

clearSelection

public void clearSelection()

getSelection

public java.lang.String getSelection()
Description copied from interface: VDUDisplay
Return the currently selected text from the terminal.

Specified by:
getSelection in interface VDUDisplay
Returns:
selected text

getScrollBar

public VDUScrollBar getScrollBar()
Description copied from interface: VDUDisplay
Get the scrollbar (if any) that this display is using

Specified by:
getScrollBar in interface VDUDisplay
Returns:
scrollbar

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent evt)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent evt)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

keyTyped

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

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener listener)

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)

removeMouseMotionListener

public void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)

processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent evt)

processMouseMotionEvent

public void processMouseMotionEvent(java.awt.event.MouseEvent evt)

getMouseWheelIncrement

public int getMouseWheelIncrement()

setMouseWheelIncrement

public void setMouseWheelIncrement(int mouseWheelIncrement)
Description copied from interface: VDUDisplay
Set the mouse wheel increment in lines. I.e., if the user scrolls 3 clicks and the increment is 2, then the terminal display will be scrolled 6 lines.

Specified by:
setMouseWheelIncrement in interface VDUDisplay
Parameters:
mouseWheelIncrement - mouse wheel increment

processEvent

public void processEvent(java.awt.AWTEvent evt)

addKeyListener

public void addKeyListener(java.awt.event.KeyListener listener)

removeKeyListener

public void removeKeyListener(java.awt.event.KeyListener listener)

processKeyEvent

public void processKeyEvent(java.awt.event.KeyEvent evt)

addFocusListener

public void addFocusListener(java.awt.event.FocusListener listener)

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener listener)

processFocusEvent

public void processFocusEvent(java.awt.event.FocusEvent evt)

getComponent

public java.awt.Component getComponent()
Description copied from interface: VDUDisplay
Get the component. This will be added to container applications UI.

Specified by:
getComponent in interface VDUDisplay
Returns:
VDU display component

getResizeStrategy

public int getResizeStrategy()
Description copied from interface: VDUDisplay
Return the current resize strategy. Can be one of :-

Specified by:
getResizeStrategy in interface VDUDisplay
Returns:
resize strategy

setDefaultBackground

public void setDefaultBackground(java.awt.Color color)
Description copied from interface: VDUDisplay
Set the default background color of the terminal

Specified by:
setDefaultBackground in interface VDUDisplay
Parameters:
color - default background color

setDefaultForeground

public void setDefaultForeground(java.awt.Color color)
Description copied from interface: VDUDisplay
Set the default background color of the terminal

Specified by:
setDefaultForeground in interface VDUDisplay
Parameters:
color - default background color

setTerminalFont

public void setTerminalFont(java.awt.Font font)
Description copied from interface: VDUDisplay
Set the default font

Specified by:
setTerminalFont in interface VDUDisplay
Parameters:
font - default font

getTerminalFont

public java.awt.Font getTerminalFont()
Description copied from interface: VDUDisplay
Get the terminal font

Specified by:
getTerminalFont in interface VDUDisplay
Returns:
terminal font

setCursorStyle

public void setCursorStyle(int cursorStyle)
Description copied from interface: VDUDisplay

Set the cursor style. Can be one of :-

Specified by:
setCursorStyle in interface VDUDisplay
Parameters:
cursorStyle - cursor style

getCursorStyle

public int getCursorStyle()
Description copied from interface: VDUDisplay

Get the cursor style. Can be one of :-

Specified by:
getCursorStyle in interface VDUDisplay
Returns:
cursor style

setCursorBlink

public void setCursorBlink(boolean blink)
Description copied from interface: VDUDisplay
Set whether the cursor shoud blink or not.

Specified by:
setCursorBlink in interface VDUDisplay
Parameters:
blink - cursor blink

isCursorBlink

public boolean isCursorBlink()
Description copied from interface: VDUDisplay
Get whether the cursor shoud blink or not.

Specified by:
isCursorBlink in interface VDUDisplay
Returns:
blink cursor

focusTerminal

public void focusTerminal()
Description copied from interface: VDUDisplay
Terminal component requests focus

Specified by:
focusTerminal in interface VDUDisplay

isReverseVideo

public boolean isReverseVideo()
Description copied from interface: VDUDisplay
Get whether reverse video is currently enabled

Specified by:
isReverseVideo in interface VDUDisplay
Returns:
reverse video

setReverseVideo

public void setReverseVideo(boolean reverseVideo)
Description copied from interface: VDUDisplay
Set whether reverse video is enabled

Specified by:
setReverseVideo in interface VDUDisplay
Parameters:
reverseVideo - reverse video

addNotify

public void addNotify()


Copyright © 2003-2004 3SP LTD. All Rights Reserved.