edu.princeton.swing
Class PTextField
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.text.JTextComponent
|
+--javax.swing.JTextField
|
+--edu.princeton.swing.PTextField
- All Implemented Interfaces:
- Accessible, ClipboardTarget, ImageObserver, MenuContainer, Scrollable, Serializable, SwingConstants
- public class PTextField
- extends JTextField
- implements ClipboardTarget
PTextField extends JTextField to provide ClipboardTarget support.
- See Also:
- Serialized Form
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
|
Method Summary |
void |
addActionListener(ActionListener listener)
Adds a listener to monitor action events (enter key events) on the PTextField. |
boolean |
canCopy()
Returns wheter or not the copy operation can be performed on this ClipboardTarget. |
boolean |
canCut()
Returns wheter or not the cut operation can be performed on this ClipboardTarget. |
boolean |
canPaste()
Returns wheter or not the paste operation can be performed on this ClipboardTarget. |
boolean |
canSelectAll()
Returns wheter or not the selectAll operation can be performed on this ClipboardTarget. |
String |
getActionCommand()
Returns the action command associated with the enter key being pressed. |
JPopupMenu |
getPopupMenu()
Gets the popup menu for this component. |
protected void |
processFocusEvent(FocusEvent e)
Intercept FocusEvents to notify the ClipboardTargetManager of the event. |
protected void |
processKeyEvent(KeyEvent e)
Intercept KeyEvents to send off ActionEvents when enter is pressed. |
protected void |
processMouseEvent(MouseEvent e)
Intercept MouseEvents to activate the popupMenu at the right time. |
void |
removeActionListener(ActionListener listener)
Removes a listener from this component. |
void |
setActionCommand(String actionCommand)
Sets the action command associated with the enter key being pressed. |
void |
setEditable(boolean editable)
Override the setEditable() method to intercept any changes concerning the editable status of
the component. |
void |
setEnabled(boolean enabled)
Override the setEnabled() method to intercept any changes concerning the enabled status of
the component. |
void |
setPopupMenu(JPopupMenu popupMenu)
Sets the popup menu for this component. |
| Methods inherited from class javax.swing.JTextField |
configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, scrollRectToVisible, setAction, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffset |
| Methods inherited from class javax.swing.text.JTextComponent |
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| 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, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, 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, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
PTextField
public PTextField()
- Constructs a new PTextField.
PTextField
public PTextField(Document doc,
String text,
int columns)
- Constructs a new PTextField.
PTextField
public PTextField(int columns)
- Constructs a new PTextField.
PTextField
public PTextField(String text)
- Constructs a new PTextField.
PTextField
public PTextField(String text,
int columns)
- Constructs a new PTextField.
addActionListener
public void addActionListener(ActionListener listener)
- Adds a listener to monitor action events (enter key events) on the PTextField.
- Overrides:
addActionListener in class JTextField
- Parameters:
listener - The listener to add to this document. A null value will cause a
NullPointerException.
removeActionListener
public void removeActionListener(ActionListener listener)
- Removes a listener from this component. Nothing will happen if no match was found.
- Overrides:
removeActionListener in class JTextField
- Parameters:
listener - The listener to remove from this document. A null value will cause a
NullPointerException.
getActionCommand
public String getActionCommand()
- Returns the action command associated with the enter key being pressed. A null value
indicates thatthe text of the text field at the time of the event will be used.
return The action command to be associated with the enter key.
setActionCommand
public void setActionCommand(String actionCommand)
- Sets the action command associated with the enter key being pressed.
- Overrides:
setActionCommand in class JTextField
- Parameters:
actionCommand - The action command to be associated with the enter key. If null is
passed, the text of the text field at the time of the event will be used.
canCut
public boolean canCut()
- Returns wheter or not the cut operation can be performed on this ClipboardTarget.
- Specified by:
canCut in interface ClipboardTarget
- Returns:
- True iff a call to cut() should be permitted.
canCopy
public boolean canCopy()
- Returns wheter or not the copy operation can be performed on this ClipboardTarget.
- Specified by:
canCopy in interface ClipboardTarget
- Returns:
- True iff a call to copy() should be permitted.
canPaste
public boolean canPaste()
- Returns wheter or not the paste operation can be performed on this ClipboardTarget.
- Specified by:
canPaste in interface ClipboardTarget
- Returns:
- True iff a call to paste() should be permitted.
canSelectAll
public boolean canSelectAll()
- Returns wheter or not the selectAll operation can be performed on this ClipboardTarget.
- Specified by:
canSelectAll in interface ClipboardTarget
- Returns:
- True iff a call to selectAll() should be permitted.
processKeyEvent
protected void processKeyEvent(KeyEvent e)
- Intercept KeyEvents to send off ActionEvents when enter is pressed.
- Overrides:
processKeyEvent in class JComponent
processFocusEvent
protected void processFocusEvent(FocusEvent e)
- Intercept FocusEvents to notify the ClipboardTargetManager of the event.
- Overrides:
processFocusEvent in class Component
processMouseEvent
protected void processMouseEvent(MouseEvent e)
- Intercept MouseEvents to activate the popupMenu at the right time.
- Overrides:
processMouseEvent in class Component
setEnabled
public void setEnabled(boolean enabled)
- Override the setEnabled() method to intercept any changes concerning the enabled status of
the component.
- Overrides:
setEnabled in class JComponent
setEditable
public void setEditable(boolean editable)
- Override the setEditable() method to intercept any changes concerning the editable status of
the component.
- Overrides:
setEditable in class JTextComponent
getPopupMenu
public JPopupMenu getPopupMenu()
- Gets the popup menu for this component.
- Returns:
- The popup menu for the component. Null is returned if this component does not have
a popup menu.
setPopupMenu
public void setPopupMenu(JPopupMenu popupMenu)
- Sets the popup menu for this component.
- Parameters:
popupMenu - The popup menu for the component. A null value indicates that this
component should not have a popup menu.