Class CheckedTextField

    • Field Detail

      • m_DefaultForeground

        protected Color m_DefaultForeground
        the default foreground color.
      • m_IgnoreUpdates

        protected boolean m_IgnoreUpdates
        whether to ignore updates to the text.
    • Constructor Detail

      • CheckedTextField

        public CheckedTextField()
        Constructs a new TextField. A default model is created, the initial string is null, and the number of columns is set to 0. A StringCheckModel is used.
      • CheckedTextField

        public CheckedTextField​(CheckedTextField.AbstractCheckModel model)
        Constructs a new TextField. A default model is created, the initial string is null, and the number of columns is set to 0. The provided model is used.
        Parameters:
        model - the check model to use
      • CheckedTextField

        public CheckedTextField​(String text)
        Constructs a new TextField initializeCheckModeld with the specified text. A default model is created and the number of columns is 0. A StringCheckModel is used.
        Parameters:
        text - the text to be displayed, or null
      • CheckedTextField

        public CheckedTextField​(String text,
                                CheckedTextField.AbstractCheckModel model)
        Constructs a new TextField initializeCheckModeld with the specified text. A default model is created and the number of columns is 0. The provided model is used.
        Parameters:
        text - the text to be displayed, or null
        model - the check model to use
      • CheckedTextField

        public CheckedTextField​(int columns)
        Constructs a new empty TextField with the specified number of columns. A default model is created and the initial string is set to null. A StringCheckModel is used.
        Parameters:
        columns - the number of columns to use to calculate the preferred width; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation
      • CheckedTextField

        public CheckedTextField​(int columns,
                                CheckedTextField.AbstractCheckModel model)
        Constructs a new empty TextField with the specified number of columns. A default model is created and the initial string is set to null. The provided model is used.
        Parameters:
        columns - the number of columns to use to calculate the preferred width; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation
        model - the check model to use
      • CheckedTextField

        public CheckedTextField​(String text,
                                int columns)
        Constructs a new TextField initializeCheckModeld with the specified text and columns. A default model is created. A StringCheckModel is used.
        Parameters:
        text - the text to be displayed, or null
        columns - the number of columns to use to calculate the preferred width; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation
      • CheckedTextField

        public CheckedTextField​(String text,
                                int columns,
                                CheckedTextField.AbstractCheckModel model)
        Constructs a new TextField initializeCheckModeld with the specified text and columns. A default model is created. The provided model is used.
        Parameters:
        text - the text to be displayed, or null
        columns - the number of columns to use to calculate the preferred width; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation
        model - the check model to use
      • CheckedTextField

        public CheckedTextField​(Document doc,
                                String text,
                                int columns)
        Constructs a new BaseTextField that uses the given text storage model and the given number of columns. This is the constructor through which the other constructors feed. If the document is null, a default model is created. A StringCheckModel is used.
        Parameters:
        doc - the text storage to use; if this is null, a default will be provided by calling the createDefaultModel method
        text - the initial string to display, or null
        columns - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation
      • CheckedTextField

        public CheckedTextField​(Document doc,
                                String text,
                                int columns,
                                CheckedTextField.AbstractCheckModel model)
        Constructs a new BaseTextField that uses the given text storage model and the given number of columns. This is the constructor through which the other constructors feed. If the document is null, a default model is created. The provided model is used.
        Parameters:
        doc - the text storage to use; if this is null, a default will be provided by calling the createDefaultModel method
        text - the initial string to display, or null
        columns - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation
        model - the check model to use
    • Method Detail

      • initializeCheckModel

        protected void initializeCheckModel()
        Initializes the model.
      • initialize

        protected void initialize()
        Initializes the members.
      • indicateValidity

        protected void indicateValidity()
        Updates the color of the border, indicating with RED if the input is invalid.
      • attachListener

        protected void attachListener()
        Adds a listener to the document that checks the correctness of the input.
      • copyToClipboard

        protected void copyToClipboard()
        Copies the current settings to the clipboard.
      • pasteFromClipboard

        protected void pasteFromClipboard()
        Pastes the string representation from the clipboard.
      • getPopupMenu

        protected BasePopupMenu getPopupMenu()
        Returns a popup menu when right-clicking on the edit field.
        Returns:
        the menu, null if non available
      • setCheckModel

        public void setCheckModel​(CheckedTextField.AbstractCheckModel value)
        Sets the underlying check model.
        Parameters:
        value - the model for checking the input
      • setText

        public void setText​(String t)
        Sets the text, but only if it is valid according to the current model.
        Overrides:
        setText in class JTextComponent
        Parameters:
        t - the text to set
      • setTextUnchecked

        protected void setTextUnchecked​(String value)
        Bypasses the checks when setting the text.
        Parameters:
        value - the text to set
      • getTextUnchecked

        protected String getTextUnchecked()
        Returns the raw text currently being displayed.
        Returns:
        the raw text or null if not
      • getText

        public String getText()
        Returns the text. If the current input is not valid, then the default value will be returned.
        Overrides:
        getText in class JTextComponent
        Returns:
        the current text
      • isValid

        public boolean isValid()
        Returns whether the current input string is valid.
        Overrides:
        isValid in class Component
        Returns:
        true if the input string is valid
      • getHelpText

        public String getHelpText()
        The help string (can be HTML) to use as tool tip.
        Default implementation returns null.
        Returns:
        the tool tip, null if none available
      • toString

        public String toString()
        Returns a short string representation.
        Overrides:
        toString in class Component
        Returns:
        the representation