public final class Terminal
extends javax.swing.JComponent
implements java.lang.Runnable, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static java.io.InputStream |
NULL_INPUT_STREAM
Fake InputStream that is always at end-of-file.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
Terminal(java.io.InputStream is,
java.io.OutputStream os,
java.lang.String portName,
boolean echoed)
Create a Terminal screen widget for managing the named connection, optionally opening input and
output streams from and to that connection.
|
Modifier and Type | Method and Description |
---|---|
void |
addAutoFlush(char ch)
Add another character to the set of user-typed characters that cause a
output stream flush.
|
void |
close()
Shut down a Terminal and close the I/O streams it is connected to.
|
void |
displayLocalText(java.lang.String text)
Display the programmatically-generated text on the Terminal screen.
|
int |
getHeight()
Returns the current height of this component.
|
java.awt.Dimension |
getMinimumSize()
If the minimum size has been set to a non-
null value
just returns it. |
java.awt.Dimension |
getPreferredSize()
If the
preferredSize has been set to a
non-null value just returns it. |
int |
getWidth()
Returns the current width of this component.
|
void |
keyPressed(java.awt.event.KeyEvent e)
Invoked when a key has been pressed.
|
void |
keyReleased(java.awt.event.KeyEvent e)
Invoked when a key has been released.
|
void |
keyTyped(java.awt.event.KeyEvent e)
Invoked when a key has been typed.
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse button has been clicked (pressed
and released) on a component.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then
dragged.
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component.
|
void |
mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component.
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse cursor has been moved onto a component
but no buttons have been pushed.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component.
|
protected void |
paintComponent(java.awt.Graphics g) |
void |
removeAutoFlush(char ch)
Remove a character from the set of user-typed characters that cause a
output stream flush.
|
void |
run()
DO NOT CALL.
|
void |
setDoAutoLF(boolean doAutoLF)
Specify whether a linefeed should be injected automatically after a carriage
return if a linefeed is not explicitly provided by the remote system.
|
void |
setInputStream(java.io.InputStream is)
Set the InputStream to read for characters to display.
|
void |
setOutputStream(java.io.OutputStream os)
Set the OutputStream to write user-typed characters.
|
static void |
showTerminal(java.io.InputStream is,
java.io.OutputStream os,
boolean closeStreamsOnClose,
javax.swing.JComponent parent,
java.lang.String portType,
java.lang.String portName)
Create a modal Terminal dialog window for the specified pair of streams
|
void |
validate()
Validates this container and all of its subcomponents.
|
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, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
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, transferFocusDownCycle, validateTree
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, getAccessibleContext, 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, 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, transferFocusBackward, transferFocusUpCycle
public static final java.io.InputStream NULL_INPUT_STREAM
public Terminal(java.io.InputStream is, java.io.OutputStream os, java.lang.String portName, boolean echoed)
is
- InputStream to read for characters to display on the screen widget, or null to not open the stream yetos
- OutputStream to write keyboard characters to, or null to not provide an OutputStream yetportName
- String name to title the screen widgetechoed
- boolean true if characters typed into the widget by the user should be displayed, rather than
waiting for an echo-back from the connectionpublic void setInputStream(java.io.InputStream is)
is
- InputStream to readpublic void setOutputStream(java.io.OutputStream os) throws java.lang.IllegalStateException
os
- OutputStream to writejava.lang.IllegalStateException
public void setDoAutoLF(boolean doAutoLF)
doAutoLF
- boolean true if automatic linefeed injection should be performedpublic void addAutoFlush(char ch)
ch
- char to addpublic void removeAutoFlush(char ch)
ch
- char to removepublic int getHeight()
component.getBounds().height
, or
component.getSize().height
because it doesn't cause any
heap allocations.getHeight
in class javax.swing.JComponent
public int getWidth()
component.getBounds().width
, or
component.getSize().width
because it doesn't cause any
heap allocations.getWidth
in class javax.swing.JComponent
public void validate()
The validate
method is used to cause a container
to lay out its subcomponents again. It should be invoked when
this container's subcomponents are modified (added to or
removed from the container, or layout-related information
changed) after the container has been displayed.
If this Container
is not valid, this method invokes
the validateTree
method and marks this Container
as valid. Otherwise, no action is performed.
validate
in class java.awt.Container
Container.add(java.awt.Component)
,
Component.invalidate()
,
JComponent.revalidate()
,
Container.validateTree()
public java.awt.Dimension getMinimumSize()
null
value
just returns it. If the UI delegate's getMinimumSize
method returns a non-null
value then return that; otherwise
defer to the component's layout manager.getMinimumSize
in class javax.swing.JComponent
minimumSize
propertypublic java.awt.Dimension getPreferredSize()
preferredSize
has been set to a
non-null
value just returns it.
If the UI delegate's getPreferredSize
method returns a non null
value then return that;
otherwise defer to the component's layout manager.getPreferredSize
in class javax.swing.JComponent
preferredSize
propertyprotected void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- the Graphics
object to protectpublic final void run()
run
in interface java.lang.Runnable
public void close()
public void displayLocalText(java.lang.String text)
text
- String to append (as if it was received at this instant from the input stream); string should be less than 128 characters longpublic void keyPressed(java.awt.event.KeyEvent e)
KeyEvent
for a definition of
a key pressed event.keyPressed
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent e)
KeyEvent
for a definition of
a key typed event.keyTyped
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
KeyEvent
for a definition of
a key released event.keyReleased
in interface java.awt.event.KeyListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
MOUSE_DRAGGED
events will continue to be
delivered to the component where the drag originated until the
mouse button is released (regardless of whether the mouse position
is within the bounds of the component).
Due to platform-dependent Drag and Drop implementations,
MOUSE_DRAGGED
events may not be delivered during a native
Drag and Drop operation.
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public static void showTerminal(java.io.InputStream is, java.io.OutputStream os, boolean closeStreamsOnClose, javax.swing.JComponent parent, java.lang.String portType, java.lang.String portName) throws java.io.IOException
is
- InputStream to read from remote connectionos
- OutputStream to write user keyboard input to remote connectioncloseStreamsOnClose
- boolean true if streams should be closed when dialog window is closedparent
- JComponent widget that is the windowing system parent of this created dialog windowportType
- String of port type that should be displayed in the dialog window title barportName
- String of specific port instance name that should be displayed in the dialog window title barjava.io.IOException
- if terminal could not accept streams or streams could not be closed successfully when the dialog was dismissed