Package bsh.util
Class AWTConsole
- java.lang.Object
- 
- java.awt.Component
- 
- java.awt.TextComponent
- 
- java.awt.TextArea
- 
- bsh.util.AWTConsole
 
 
 
 
- 
- All Implemented Interfaces:
- ConsoleInterface,- KeyListener,- ImageObserver,- MenuContainer,- Serializable,- Runnable,- EventListener,- Accessible
 
 public class AWTConsole extends TextArea implements ConsoleInterface, Runnable, KeyListener An old AWT based console for BeanShell. I looked everwhere for one, and couldn't find anything that worked. I've tried to keep this as small as possible, no frills. (Well, one frill - a simple history with the up/down arrows) My hope is that this can be moved to a lightweight (portable) component with JFC soon... but Swing is still very slow and buggy. Done: see JConsole.java The big Hack: The heinous, disguisting hack in here is to keep the caret (cursor) at the bottom of the text (without the user having to constantly click at the bottom). It wouldn't be so bad if the damned setCaretPostition() worked as expected. But the AWT TextArea for some insane reason treats NLs as characters... oh, and it refuses to let you set a caret position greater than the text length - for which it counts NLs as *one* character. The glorious hack to fix this is to go the TextComponent peer. I really hate this. Out of date: This class is out of date. It does not use the special blocking piped input stream that the jconsole uses. Deprecation: This file uses two deprecate APIs. We want to be a PrintStream so that we can redirect stdout to our console... I don't see a way around this. Also we have to use getPeer() for the big hack above.- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class java.awt.TextAreaTextArea.AccessibleAWTTextArea
 - 
Nested classes/interfaces inherited from class java.awt.TextComponentTextComponent.AccessibleAWTTextComponent
 - 
Nested classes/interfaces inherited from class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
- 
 - 
Field Summary- 
Fields inherited from class java.awt.TextAreaSCROLLBARS_BOTH, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, SCROLLBARS_VERTICAL_ONLY
 - 
Fields inherited from class java.awt.TextComponenttextListener
 - 
Fields inherited from class java.awt.ComponentaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 - 
Fields inherited from interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
- 
 - 
Constructor SummaryConstructors Constructor Description AWTConsole()AWTConsole(int rows, int cols, InputStream cin, OutputStream cout)AWTConsole(InputStream in, OutputStream out)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiderror(Object o)PrintStreamgetErr()ReadergetIn()PrintStreamgetOut()voidkeyPressed(KeyEvent e)voidkeyReleased(KeyEvent e)voidkeyTyped(KeyEvent e)static voidmain(String[] args)voidprint(Object o)voidprint(Object o, Color c)voidprintln(Object o)voidrun()voidsetCaretPosition(int pos)StringtoString()voidtype(int code, char ch, int modifiers)- 
Methods inherited from class java.awt.TextAreaaddNotify, append, appendText, getAccessibleContext, getColumns, getMinimumSize, getMinimumSize, getPreferredSize, getPreferredSize, getRows, getScrollbarVisibility, insert, insertText, minimumSize, minimumSize, paramString, preferredSize, preferredSize, replaceRange, replaceText, setColumns, setRows
 - 
Methods inherited from class java.awt.TextComponentaddTextListener, enableInputMethods, getBackground, getCaretPosition, getInputMethodRequests, getListeners, getSelectedText, getSelectionEnd, getSelectionStart, getText, getTextListeners, isEditable, processEvent, processTextEvent, removeNotify, removeTextListener, select, selectAll, setBackground, setEditable, setSelectionEnd, setSelectionStart, setText
 - 
Methods inherited from class java.awt.Componentaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
- 
 
- 
- 
- 
Constructor Detail- 
AWTConsolepublic AWTConsole(int rows, int cols, InputStream cin, OutputStream cout)
 - 
AWTConsolepublic AWTConsole() 
 - 
AWTConsolepublic AWTConsole(InputStream in, OutputStream out) 
 
- 
 - 
Method Detail- 
getInpublic Reader getIn() - Specified by:
- getInin interface- ConsoleInterface
 
 - 
getOutpublic PrintStream getOut() - Specified by:
- getOutin interface- ConsoleInterface
 
 - 
getErrpublic PrintStream getErr() - Specified by:
- getErrin interface- ConsoleInterface
 
 - 
keyPressedpublic void keyPressed(KeyEvent e) - Specified by:
- keyPressedin interface- KeyListener
 
 - 
typepublic void type(int code, char ch, int modifiers)
 - 
setCaretPositionpublic void setCaretPosition(int pos) - Overrides:
- setCaretPositionin class- TextComponent
 
 - 
printlnpublic void println(Object o) - Specified by:
- printlnin interface- ConsoleInterface
 
 - 
errorpublic void error(Object o) - Specified by:
- errorin interface- ConsoleInterface
 
 - 
printpublic void print(Object o) - Specified by:
- printin interface- ConsoleInterface
 
 - 
mainpublic static void main(String[] args) 
 - 
keyTypedpublic void keyTyped(KeyEvent e) - Specified by:
- keyTypedin interface- KeyListener
 
 - 
keyReleasedpublic void keyReleased(KeyEvent e) - Specified by:
- keyReleasedin interface- KeyListener
 
 
- 
 
-