tecgraf.javautils.gui.field
Class DateField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextField
                      extended by tecgraf.javautils.gui.field.AbstractRegexField
                          extended by tecgraf.javautils.gui.field.DateField
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants

public class DateField
extends AbstractRegexField

Campo para Data. A máscara do campo é criada de acordo com o Locale usado no construtor. O construtor default obtém o Locale do LNG. Os locales permitidos são: pt_BR, es_AR e en_US. Caso o Locale usado no construtor não seja um dos permitidos, o pt_BR será usado. O componente possui métodos para validar e obter os valores da data assim como setar a data atual.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextField
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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 tecgraf.javautils.gui.field.AbstractRegexField
ANY_STRING_REGEX
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DateField()
          Constrói um DateField com validação visual desabilitada.
DateField(boolean showValidation)
          Constrói um DateField.
DateField(Locale locale)
          Constrói um DateField com validação visual desabilitada para um determinado Locale.
DateField(Locale locale, boolean showValidation)
          Constrói um DateField para um determinado Locale.
 
Method Summary
 void addDateListener(DateListener listener)
          Adiciona um listener de data
 Long getDate()
          Obtém a data em milisegundos ou NULL caso data seja inválida.
static Date getDate(String date, Locale locale)
          Deprecated. Utilizar o método DateDocument.getDate
 Integer getDay()
          Obtém o dia ou NULL caso a data não esteja válida.
 String getMask()
          Obtém a tradução LNG para a máscara usada no campo
 Integer getMonth()
          Obtém o mês ou NULL caso a data não esteja válida.
 Integer getYear()
          Obtém o ano ou NULL caso a data não esteja válida.
 boolean isValidValue()
          Verifica se o valor do campo é válido.
 void removeDateListener(DateListener listener)
          Remove um listener de data
 void setAutoComplete(boolean complete)
          Ativa o auto complemento.
 void setDate(int day, int month, int year)
          Seta o campo com uma data.
 void setDate(long lngDate)
          Seta o campo com uma data em milisegundos
 void setDocument(Document doc)
           
 void setLocale(Locale locale)
           
 void setToCurrentDate()
          Seta o campo com a data atual
 String toString()
          Obtém o texto do campo.
static String toString(Locale locale, long date)
          Deprecated. Utilizar o método DateDocument.toString
static boolean validateDate(String date, Locale locale)
          Deprecated. Utilizar o método DateDocument.validateDateFormat
static boolean validateDateFormat(String date, Locale locale)
          Deprecated. Utilizar o método DateDocument.validateDateFormat
 
Methods inherited from class tecgraf.javautils.gui.field.AbstractRegexField
enableBackgroundError, getRegexDocument, setBackgroundError, setBackgroundError, setBackgroundErrorColor, setForegroundError, setForegroundErrorColor, setText
 
Methods inherited from class javax.swing.JTextField
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, 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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateField

public DateField()
Constrói um DateField com validação visual desabilitada. O Locale usado será obtido do LNG.


DateField

public DateField(boolean showValidation)
Constrói um DateField. O Locale usado será obtido do LNG

Parameters:
showValidation - exibir efeito visual de validação

DateField

public DateField(Locale locale)
Constrói um DateField com validação visual desabilitada para um determinado Locale.

Parameters:
locale - Locale

DateField

public DateField(Locale locale,
                 boolean showValidation)
Constrói um DateField para um determinado Locale.

Parameters:
locale - Locale
showValidation - exibir efeito visual de validação
Method Detail

setLocale

public void setLocale(Locale locale)
Overrides:
setLocale in class Component

isValidValue

public boolean isValidValue()
Description copied from class: AbstractRegexField
Verifica se o valor do campo é válido.

Specified by:
isValidValue in class AbstractRegexField
Returns:
boolean

validateDate

@Deprecated
public static boolean validateDate(String date,
                                              Locale locale)
Deprecated. Utilizar o método DateDocument.validateDateFormat

Verifica se uma data está no formato válido.

Parameters:
date - String da data
locale - Locale para a data
Returns:
boolean

validateDateFormat

@Deprecated
public static boolean validateDateFormat(String date,
                                                    Locale locale)
Deprecated. Utilizar o método DateDocument.validateDateFormat

Verifica se uma data está no formato válido.

Parameters:
date - String da data
locale - Locale para a data
Returns:
boolean

getDate

@Deprecated
public static Date getDate(String date,
                                      Locale locale)
Deprecated. Utilizar o método DateDocument.getDate

Obtém um Date referente a data ou NULL caso a data esteja errada.

Parameters:
date - Data em String
locale - Locale em que se encontra a data
Returns:
array de interger com a data

getDay

public Integer getDay()
Obtém o dia ou NULL caso a data não esteja válida.

Returns:
Integer

getMonth

public Integer getMonth()
Obtém o mês ou NULL caso a data não esteja válida.

Returns:
Integer

getYear

public Integer getYear()
Obtém o ano ou NULL caso a data não esteja válida.

Returns:
Integer

getDate

public Long getDate()
Obtém a data em milisegundos ou NULL caso data seja inválida.

Returns:
Long

setAutoComplete

public void setAutoComplete(boolean complete)
Ativa o auto complemento.

Parameters:
complete -

setDate

public void setDate(int day,
                    int month,
                    int year)
Seta o campo com uma data.

Parameters:
day - Dia
month - Mês
year - Ano

toString

@Deprecated
public static String toString(Locale locale,
                                         long date)
Deprecated. Utilizar o método DateDocument.toString

Obtém uma String de data formatada

Parameters:
locale - Locale usado para formatar a data
date - Data em milisegundos
Returns:
String

setDate

public void setDate(long lngDate)
Seta o campo com uma data em milisegundos

Parameters:
lngDate -

setToCurrentDate

public void setToCurrentDate()
Seta o campo com a data atual


getMask

public String getMask()
Obtém a tradução LNG para a máscara usada no campo

Returns:
String

toString

public String toString()
Obtém o texto do campo.

Overrides:
toString in class Component
Returns:
String

setDocument

public void setDocument(Document doc)
Overrides:
setDocument in class JTextField

addDateListener

public void addDateListener(DateListener listener)
Adiciona um listener de data

Parameters:
listener - DateListener

removeDateListener

public void removeDateListener(DateListener listener)
Remove um listener de data

Parameters:
listener - DateListener


Copyright © 2014 Tecgraf/PUC-Rio. All rights reserved.