org.rapla.components.calendar
Class AbstractBlockField
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
org.rapla.components.calendar.AbstractBlockField
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants
- Direct Known Subclasses:
- DateField, NumberField, TimeField
public abstract class AbstractBlockField
- extends JTextField
The base class for TextFields that supports entering values in
blocks. Most notifiably the DateField and the TimeField.
You
can use the left/right arrow keys to switch the blocks. Use of the
top/down arrow keys will increase/decrease the values in the
selected block (page_up/page_down for major changes). You can
specify maximum length for each block. If a block reaches this
maximum value the focus will switch to the next block.
- See Also:
DateField
,
TimeField
,
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 |
addChangeListener(ChangeListener listener)
|
protected void |
beep()
this method will be called when an non-valid character is entered. |
protected abstract int |
blockCount()
The number of blocks for this Component. |
abstract boolean |
blocksValid()
returns true if the text can be split into blocks. |
protected int |
calcBlocks(int[] blockstart)
Calculate the blocks. |
protected abstract void |
changeSelectedBlock(int[] blocks,
int block,
String selected,
int count)
This method will be called, when the user has pressed the up/down
arrows on a selected block. |
protected Document |
createDefaultModel()
|
protected void |
fireValueChanged()
A ChangeEvent will be fired to every registered ActionListener
when the value has changed. |
ChangeListener[] |
getChangeListeners()
|
protected abstract char[] |
getSeparators()
|
protected abstract boolean |
isSeparator(char c)
returns true if the character is a block-separator. |
protected abstract boolean |
isValidChar(char c)
returns true if the character should be accepted by the component. |
protected void |
mark(int dot,
int mark)
Select the text from dot to mark. |
protected void |
markBlock(int[] blockstart,
int block)
Select the specified block. |
protected abstract int |
maxBlockLength(int block)
returns the maximum length of the specified block. |
void |
removeChangeListener(ChangeListener listener)
removes a listener from this component. |
Methods inherited from class javax.swing.JTextField |
addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, 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, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, 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, 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, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
m_oldText
protected String m_oldText
AbstractBlockField
public AbstractBlockField()
addChangeListener
public void addChangeListener(ChangeListener listener)
removeChangeListener
public void removeChangeListener(ChangeListener listener)
- removes a listener from this component.
getChangeListeners
public ChangeListener[] getChangeListeners()
fireValueChanged
protected void fireValueChanged()
- A ChangeEvent will be fired to every registered ActionListener
when the value has changed.
markBlock
protected final void markBlock(int[] blockstart,
int block)
- Select the specified block.
createDefaultModel
protected final Document createDefaultModel()
- Overrides:
createDefaultModel
in class JTextField
calcBlocks
protected int calcBlocks(int[] blockstart)
- Calculate the blocks. The new blockstarts will be stored in
the int array.
- Returns:
- the block that contains the caret.
mark
protected void mark(int dot,
int mark)
- Select the text from dot to mark.
beep
protected void beep()
- this method will be called when an non-valid character is entered.
blocksValid
public abstract boolean blocksValid()
- returns true if the text can be split into blocks.
blockCount
protected abstract int blockCount()
- The number of blocks for this Component.
changeSelectedBlock
protected abstract void changeSelectedBlock(int[] blocks,
int block,
String selected,
int count)
- This method will be called, when the user has pressed the up/down
arrows on a selected block.
- Parameters:
count
- Posible values are 1,-1,10,-10.
maxBlockLength
protected abstract int maxBlockLength(int block)
- returns the maximum length of the specified block.
isValidChar
protected abstract boolean isValidChar(char c)
- returns true if the character should be accepted by the component.
isSeparator
protected abstract boolean isSeparator(char c)
- returns true if the character is a block-separator. All block-separators must
be valid characters.
- See Also:
isValidChar(char)
getSeparators
protected abstract char[] getSeparators()
- Returns:
- all seperators.
Copyright © 2000-2006 Rapla Team. All Rights Reseserved.