java.awt.event.AdjustmentListener, java.awt.event.ComponentListener, java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListenerpublic class JMText
extends java.awt.Container
implements java.awt.event.AdjustmentListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ComponentListener, java.awt.event.FocusListener
| Modifier and Type | Field | Description |
|---|---|---|
static int |
SCROLLBARS_BOTH |
JMSwingTextPane, a antialiasing TextPane
|
static int |
SCROLLBARS_HORIZONTAL_ONLY |
Do not show scroll bars
|
static int |
SCROLLBARS_NONE |
Show only horizontal scroll bars
|
static int |
SCROLLBARS_VERTICAL_ONLY |
Show only vertical scroll bars
|
| Constructor | Description |
|---|---|
JMText() |
JMText, a multi-colour text-area for Java 1.1
(originally developed for JamochaMUD)
|
JMText(int rows,
int columns) |
JMText, a multi-colour text-area for Java 1.1
(originally developed for JamochaMUD)
|
JMText(java.lang.String text) |
JMText, a multi-colour text-area for Java 1.1
(originally developed for JamochaMUD)
|
JMText(java.lang.String text,
int rows,
int columns) |
JMText, a multi-colour text-area for Java 1.1
(originally developed for JamochaMUD)
|
JMText(java.lang.String text,
int rows,
int columns,
int scrollbars) |
JMText, a multi-colour text-area for Java 1.1
(originally developed for JamochaMUD)
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addKeyListener(java.awt.event.KeyListener listener) |
Allow a KeyListener to be added to this component.
|
void |
addMouseListener(java.awt.event.MouseListener mouse) |
We need to make our own mouse-listener that'll report back
to any listeners that may've registered to this component.
|
void |
addNotify() |
This method notifies our component that it has been added to a new object.
|
void |
addTextListener(java.awt.event.TextListener listener) |
Allow a TextListener to be added to this component.
|
void |
adjustmentValueChanged(java.awt.event.AdjustmentEvent event) |
Monitor the scroll-bar adjustment values to see if "scrolling" of
the text is required
|
void |
append(java.lang.String str) |
Append the String to the JMText,
|
void |
appendChar(char jchar,
java.lang.String attrib) |
Append characters to JMText, one at a time, including the current attribute
|
void |
componentHidden(java.awt.event.ComponentEvent event) |
If our component is hidden this method called, and internally
recorded as being "minimised".
|
void |
componentMoved(java.awt.event.ComponentEvent event) |
An empty method
|
void |
componentResized(java.awt.event.ComponentEvent event) |
A method used to monitor if this component has been resized.
|
void |
componentShown(java.awt.event.ComponentEvent event) |
This method is called when our component is shown and internally
records the new size of our componenet and spools out any text
that may have been held while it was minimised.
|
void |
focusGained(java.awt.event.FocusEvent event) |
This method watches for the component to gain focus.
|
void |
focusLost(java.awt.event.FocusEvent event) |
Empty method.
|
java.awt.Dimension |
getPreferredSize() |
Calculate a preferred size from the text we have
|
java.lang.String |
getSelectedText() |
return a String of the text currently selected in the JMText area
|
int |
getSelectionEnd() |
Returns an integer value of where a selection ends.
|
int |
getSelectionStart() |
Returns the beginning of a selection in an integer format based on
the count of characters from the beginning of the text component.
|
java.lang.String |
getText() |
Return a string of the text-content of JMText (does not return the markings)
|
int |
getVerticalScrollbarPos() |
get the position of our vertical scrollbar
|
boolean |
isDoubleBuffer() |
Report if we use double buffering for our display redraws
|
void |
keyPressed(java.awt.event.KeyEvent event) |
The method to handle any KeyPresses.
|
void |
keyReleased(java.awt.event.KeyEvent event) |
A method to handle a key being released
|
void |
keyTyped(java.awt.event.KeyEvent event) |
A method to handle a key being typed.
|
void |
mouseClicked(java.awt.event.MouseEvent event) |
This method handles mouse clicks for this component
|
void |
mouseDragged(java.awt.event.MouseEvent event) |
The method is used to track mouse drags and properly support text
selection via the mouse.
|
void |
mouseEntered(java.awt.event.MouseEvent event) |
This method changes the cursor to the I-beam when it enters the text area.
|
void |
mouseExited(java.awt.event.MouseEvent event) |
This method changes our cursor back to the default cursor (from the I-beam)
when it leaves our component area.
|
void |
mouseMoved(java.awt.event.MouseEvent event) |
Empty method.
|
void |
mousePressed(java.awt.event.MouseEvent event) |
This method tracks when the mouse button is pressed...
|
void |
mouseReleased(java.awt.event.MouseEvent event) |
This method watches for when the mouse is released and repaints our
component.
|
void |
paint(java.awt.Graphics graphicItem) |
The paint method will be over-ridden to give us complete
control over this event
|
java.awt.Point |
pointToArray(java.awt.Point pos) |
This translates a point on the screen into a location
on our array of characters ! (This method is usually used
in conjunction with marking text)
|
void |
removeKeyListener(java.awt.event.KeyListener listener) |
Allow the removal of the given KeyListener from our component.
|
void |
removeMouseListener(java.awt.event.MouseListener mouse) |
All registered MouseListeners to be removed from this component.
|
void |
select(int selectionStart,
int selectionEnd) |
Select a given area of text which will be indicated by highlighting
|
void |
setCaretPosition(int position) |
This method allows setting of the cursor's position based on the
count of characters from the beginning of the component.
|
void |
setColumns(int newCols) |
Set the column-width of our magic widget! (That's the JMText widget,
Y'know)
|
void |
setDoubleBuffer(boolean status) |
Set our redraw status to use double buffering for our display redraws.
|
void |
setEditable(boolean edit) |
Set the JMText area to be editable or not.
|
void |
setFont(java.awt.Font newFont) |
Over-ride the setFont so that we can readjust our display
for the new font-metrics
|
void |
setMaxRows(int setMax) |
Set the maximum number of rows to be shown in the component.
|
void |
setText(java.lang.String str) |
Set the text in JMText to whatever we are sent in the string,
erasing everything else
|
void |
setVerticalScrollbarPos(int pos) |
Set the position of our vertical scrollbar
|
void |
update(java.awt.Graphics graphItem) |
This method passes to call to update the graphics on to our super-class.
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreepublic static final int SCROLLBARS_BOTH
public static final int SCROLLBARS_VERTICAL_ONLY
public static final int SCROLLBARS_HORIZONTAL_ONLY
public static final int SCROLLBARS_NONE
public JMText()
public JMText(java.lang.String text)
text - Text to be displayed after intial component creationpublic JMText(int rows,
int columns)
rows - Number of rows to be visible in the componentcolumns - Number of columns to be visible in the componentpublic JMText(java.lang.String text,
int rows,
int columns)
text - Text to initially be displayed when this component is created.rows - Number of rows to be visible in the componentcolumns - Number of columns to be visible in the componentpublic JMText(java.lang.String text,
int rows,
int columns,
int scrollbars)
text - Text to initially be displayed after creation of this componentrows - Number of rows in this componentcolumns - Number of columns in this componentscrollbars - Indicate whether scrollbars should be visible in this componentpublic void setMaxRows(int setMax)
setMax - Number of rows to be shown.public void append(java.lang.String str)
str - The string to be added to the JMTextpublic void appendChar(char jchar,
java.lang.String attrib)
jchar - the single char to be addedattrib - a "description" of the attributes of the characterpublic void paint(java.awt.Graphics graphicItem)
paint in class java.awt.ContainergraphicItem - The Graphic object that we will draw on.public void update(java.awt.Graphics graphItem)
update in class java.awt.ContainergraphItem - public void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
adjustmentValueChanged in interface java.awt.event.AdjustmentListenerevent - public void setText(java.lang.String str)
str - Text to set in the cleared JMText field.
A null will leave the JMText area blank.public void setCaretPosition(int position)
position - An integer-based position of the character counting from the
first character of the component (not the first visible character)public java.lang.String getText()
public void setDoubleBuffer(boolean status)
status - true enables double buffering while false disables itpublic boolean isDoubleBuffer()
public void select(int selectionStart,
int selectionEnd)
selectionStart - The character number (from the beginning) to start the selectionselectionEnd - The number of characters from selectionStartpublic int getSelectionEnd()
0 is returned if there is not a selection present.public int getSelectionStart()
0 will be returned if there is no selection.public java.lang.String getSelectedText()
public void setEditable(boolean edit)
edit - true indicates this area is editable, false disables editingpublic void addTextListener(java.awt.event.TextListener listener)
listener - The listener to be addedpublic void addKeyListener(java.awt.event.KeyListener listener)
addKeyListener in class java.awt.Componentlistener - The KeyListener to be added.public void removeKeyListener(java.awt.event.KeyListener listener)
removeKeyListener in class java.awt.Componentlistener - The listener to be removed.public void keyPressed(java.awt.event.KeyEvent event)
keyPressed in interface java.awt.event.KeyListenerevent - The event we are listening for.public void keyReleased(java.awt.event.KeyEvent event)
keyReleased in interface java.awt.event.KeyListenerevent - The Key Released event we are waiting for.public void keyTyped(java.awt.event.KeyEvent event)
keyTyped in interface java.awt.event.KeyListenerevent - The event we are listening for.public void componentHidden(java.awt.event.ComponentEvent event)
componentHidden in interface java.awt.event.ComponentListenerevent - The event we are listening for.public void componentMoved(java.awt.event.ComponentEvent event)
componentMoved in interface java.awt.event.ComponentListenerevent - Empty eventpublic void componentResized(java.awt.event.ComponentEvent event)
componentResized in interface java.awt.event.ComponentListenerevent - Our Component Resized Eventpublic void componentShown(java.awt.event.ComponentEvent event)
componentShown in interface java.awt.event.ComponentListenerevent - Our component event.public void addMouseListener(java.awt.event.MouseListener mouse)
addMouseListener in class java.awt.Componentmouse - The mouseListener to add to this componenet.public void removeMouseListener(java.awt.event.MouseListener mouse)
removeMouseListener in class java.awt.Componentmouse - The MouseListener to be removed.public void mouseClicked(java.awt.event.MouseEvent event)
mouseClicked in interface java.awt.event.MouseListenerevent - Our Mouse Eventpublic void mouseEntered(java.awt.event.MouseEvent event)
mouseEntered in interface java.awt.event.MouseListenerevent - Our eventpublic void mouseExited(java.awt.event.MouseEvent event)
mouseExited in interface java.awt.event.MouseListenerevent - Our mouse event.public void mousePressed(java.awt.event.MouseEvent event)
mousePressed in interface java.awt.event.MouseListenerevent - Our mouse eventpublic void mouseReleased(java.awt.event.MouseEvent event)
mouseReleased in interface java.awt.event.MouseListenerevent - Our mouse event.public void mouseDragged(java.awt.event.MouseEvent event)
mouseDragged in interface java.awt.event.MouseMotionListenerevent - Our mouse listener.public void mouseMoved(java.awt.event.MouseEvent event)
mouseMoved in interface java.awt.event.MouseMotionListenerevent - public void focusGained(java.awt.event.FocusEvent event)
focusGained in interface java.awt.event.FocusListenerevent - Our focus eventpublic void focusLost(java.awt.event.FocusEvent event)
focusLost in interface java.awt.event.FocusListenerevent - Our focus event.public java.awt.Point pointToArray(java.awt.Point pos)
pos - The coordinates of the mouse pointer in our component.public void addNotify()
addNotify in class java.awt.Containerpublic void setFont(java.awt.Font newFont)
setFont in class java.awt.ContainernewFont - The font to use in the current component.public void setVerticalScrollbarPos(int pos)
pos - The position of our vertical scrollbar.public int getVerticalScrollbarPos()
public void setColumns(int newCols)
newCols - The number of columns this component should contain.public java.awt.Dimension getPreferredSize()
getPreferredSize in class java.awt.Container