- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Panel
-
- ij.text.TextPanel
-
- All Implemented Interfaces:
ClipboardOwner,ActionListener,AdjustmentListener,KeyListener,MouseListener,MouseMotionListener,MouseWheelListener,ImageObserver,MenuContainer,Serializable,Runnable,EventListener,Accessible
public class TextPanel extends Panel implements AdjustmentListener, MouseListener, MouseMotionListener, KeyListener, ClipboardOwner, ActionListener, MouseWheelListener, Runnable
This is an unlimited size text panel with tab-delimited, labeled and resizable columns. It is based on the hGrid class at http://www.lynx.ch/contacts/~/thomasm/Grid/index.html.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(ActionEvent e)voidaddKeyListener(KeyListener listener)Unused keyPressed and keyTyped events will be passed to 'listener'.voidaddMouseListener(MouseListener listener)voidadjustmentValueChanged(AdjustmentEvent e)voidappend(String text)Adds one or more lines to the end of this TextPanel.voidappend(ArrayList list)Adds strings contained in an ArrayList to the end of this TextPanel.voidappendLine(String text)Adds a single line to the end of this TextPanel.voidappendWithoutUpdate(String data)Adds a single line to the end of this TextPanel without updating the display.voidclear()Deletes all the lines.voidclearSelection()Deletes the selected lines.intcopySelection()Copies the current selection to the system clipboard.voiddoClear()Implements the Clear command.StringgetColumnHeadings()Returns the column headings as a tab-delimited string.StringgetLine(int index)Returns the specified line as a string.intgetLineCount()Returns the number of lines of text in this TextPanel.ResultsTablegetOrCreateResultsTable()Returns the ResultsTable associated with this TextPanel, or attempts to create one and returns the created table.ResultsTablegetResultsTable()Returns the ResultsTable associated with this TextPanel, or null.intgetSelectionEnd()Returns the index of the last selected line, or -1 if there is no slection.intgetSelectionStart()Returns the index of the first selected line, or -1 if there is no slection.StringgetText()Returns all the text as a string.voidkeyPressed(KeyEvent e)voidkeyReleased(KeyEvent e)voidkeyTyped(KeyEvent e)voidlostOwnership(Clipboard clip, Transferable cont)voidmouseClicked(MouseEvent e)voidmouseDragged(MouseEvent e)voidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent e)voidmouseMoved(MouseEvent e)voidmousePressed(MouseEvent e)voidmouseReleased(MouseEvent e)voidmouseWheelMoved(MouseWheelEvent event)voidresetSelection()Clears the selection, if any.introwIndex(int y)Converts a y coordinate in pixels into a row index.voidrun()For better performance, open double-clicked files on separate thread instead of on event dispatch thread.voidsave(PrintWriter pw)Writes all the text in this TextPanel to a file.booleansaveAs(String path)Saves the text in this TextPanel to a file.voidscrollToTop()voidselectAll()Selects all the lines in this TextPanel.voidsetColumnHeadings(String labels)Clears this TextPanel and sets the column headings to those in the tab-delimited 'headings' String.voidsetFont(Font font, boolean antialiased)voidsetLine(int index, String s)Replaces the contents of the specified line, where 'index' must be greater than or equal to zero and less than the value returned by getLineCount().voidsetResultsTable(ResultsTable rt)Sets the ResultsTable associated with this TextPanel.voidsetSelection(int startLine, int endLine)Creates a selection and insures it is visible.voidsetTitle(String title)voidshowCell(int rowIndex, String column)Updates the scroll bars so that the specified cell is visible.voidshowRow(int rowIndex)Updates the vertical scroll bar so that the specified row is visible.voidupdateColumnHeadings(String labels)voidupdateDisplay()-
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
-
Methods inherited from class java.awt.Container
add, 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, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
-
Methods inherited from class java.awt.Component
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, 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, removeKeyListener, removeMouseListener, 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, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
TextPanel
public TextPanel()
Constructs a new TextPanel.
-
TextPanel
public TextPanel(String title)
Constructs a new TextPanel.
-
-
Method Detail
-
setColumnHeadings
public void setColumnHeadings(String labels)
Clears this TextPanel and sets the column headings to those in the tab-delimited 'headings' String. Set 'headings' to "" to use a single column with no headings.
-
getColumnHeadings
public String getColumnHeadings()
Returns the column headings as a tab-delimited string.
-
updateColumnHeadings
public void updateColumnHeadings(String labels)
-
setFont
public void setFont(Font font, boolean antialiased)
-
appendLine
public void appendLine(String text)
Adds a single line to the end of this TextPanel.
-
append
public void append(String text)
Adds one or more lines to the end of this TextPanel.
-
append
public void append(ArrayList list)
Adds strings contained in an ArrayList to the end of this TextPanel.
-
appendWithoutUpdate
public void appendWithoutUpdate(String data)
Adds a single line to the end of this TextPanel without updating the display.
-
updateDisplay
public void updateDisplay()
-
adjustmentValueChanged
public void adjustmentValueChanged(AdjustmentEvent e)
- Specified by:
adjustmentValueChangedin interfaceAdjustmentListener
-
mousePressed
public void mousePressed(MouseEvent e)
- Specified by:
mousePressedin interfaceMouseListener
-
run
public void run()
For better performance, open double-clicked files on separate thread instead of on event dispatch thread.
-
mouseExited
public void mouseExited(MouseEvent e)
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mouseDragged
public void mouseDragged(MouseEvent e)
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseReleased
public void mouseReleased(MouseEvent e)
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseClicked
public void mouseClicked(MouseEvent e)
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseWheelMoved
public void mouseWheelMoved(MouseWheelEvent event)
- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-
mouseEntered
public void mouseEntered(MouseEvent e)
- Specified by:
mouseEnteredin interfaceMouseListener
-
addKeyListener
public void addKeyListener(KeyListener listener)
Unused keyPressed and keyTyped events will be passed to 'listener'.- Overrides:
addKeyListenerin classComponent
-
addMouseListener
public void addMouseListener(MouseListener listener)
- Overrides:
addMouseListenerin classComponent
-
keyPressed
public void keyPressed(KeyEvent e)
- Specified by:
keyPressedin interfaceKeyListener
-
keyReleased
public void keyReleased(KeyEvent e)
- Specified by:
keyReleasedin interfaceKeyListener
-
keyTyped
public void keyTyped(KeyEvent e)
- Specified by:
keyTypedin interfaceKeyListener
-
actionPerformed
public void actionPerformed(ActionEvent e)
- Specified by:
actionPerformedin interfaceActionListener
-
lostOwnership
public void lostOwnership(Clipboard clip, Transferable cont)
- Specified by:
lostOwnershipin interfaceClipboardOwner
-
rowIndex
public int rowIndex(int y)
Converts a y coordinate in pixels into a row index.
-
copySelection
public int copySelection()
Copies the current selection to the system clipboard. Returns the number of characters copied.
-
doClear
public void doClear()
Implements the Clear command.
-
clearSelection
public void clearSelection()
Deletes the selected lines.
-
clear
public void clear()
Deletes all the lines.
-
selectAll
public void selectAll()
Selects all the lines in this TextPanel.
-
resetSelection
public void resetSelection()
Clears the selection, if any.
-
setSelection
public void setSelection(int startLine, int endLine)Creates a selection and insures it is visible.
-
showRow
public void showRow(int rowIndex)
Updates the vertical scroll bar so that the specified row is visible.
-
showCell
public void showCell(int rowIndex, String column)Updates the scroll bars so that the specified cell is visible.
-
save
public void save(PrintWriter pw)
Writes all the text in this TextPanel to a file.
-
saveAs
public boolean saveAs(String path)
Saves the text in this TextPanel to a file. Set 'path' to "" to display a "save as" dialog. Returns 'false' if the user cancels the dialog.
-
getText
public String getText()
Returns all the text as a string.
-
setTitle
public void setTitle(String title)
-
getLineCount
public int getLineCount()
Returns the number of lines of text in this TextPanel.
-
getLine
public String getLine(int index)
Returns the specified line as a string. The argument must be greater than or equal to zero and less than the value returned by getLineCount().
-
setLine
public void setLine(int index, String s)Replaces the contents of the specified line, where 'index' must be greater than or equal to zero and less than the value returned by getLineCount().
-
getSelectionStart
public int getSelectionStart()
Returns the index of the first selected line, or -1 if there is no slection.
-
getSelectionEnd
public int getSelectionEnd()
Returns the index of the last selected line, or -1 if there is no slection.
-
setResultsTable
public void setResultsTable(ResultsTable rt)
Sets the ResultsTable associated with this TextPanel.
-
getResultsTable
public ResultsTable getResultsTable()
Returns the ResultsTable associated with this TextPanel, or null.
-
getOrCreateResultsTable
public ResultsTable getOrCreateResultsTable()
Returns the ResultsTable associated with this TextPanel, or attempts to create one and returns the created table.
-
scrollToTop
public void scrollToTop()
-
-