Class NonEmptyTextButtonEnabler

java.lang.Object
org.ka2ddo.yaac.gui.util.NonEmptyTextButtonEnabler
All Implemented Interfaces:
EventListener, DocumentListener

public class NonEmptyTextButtonEnabler extends Object implements DocumentListener
This class implements a generic listener for enabling and disabling a button based on whether the associated text document contains text or not.
Author:
Andrew Pavlin, KA2DDO
  • Constructor Details

    • NonEmptyTextButtonEnabler

      public NonEmptyTextButtonEnabler(JComponent comp)
      Create a document listener that will update the enabled state of a JComponent based on whether there is any text in the document.
      Parameters:
      comp - JComponent whose enabled state should be updated
    • NonEmptyTextButtonEnabler

      public NonEmptyTextButtonEnabler(JComponent comp, ButtonModel qualifyingModel)
      Create a document listener that will update the enabled state of a JComponent based on whether there is any text in the document.
      Parameters:
      comp - JComponent whose enabled state should be updated
      qualifyingModel - ButtonModel used to indicate whether comp can be enabled
    • NonEmptyTextButtonEnabler

      public NonEmptyTextButtonEnabler(JComponent comp, JToggleButton qualifyingButton)
      Create a document listener that will update the enabled state of a JComponent based on whether there is any text in the document.
      Parameters:
      comp - JComponent whose enabled state should be updated
      qualifyingButton - JToggleButton used to indicate whether comp can be enabled
  • Method Details

    • insertUpdate

      public void insertUpdate(DocumentEvent e)
      Gives notification that there was an insert into the document. The range given by the DocumentEvent bounds the freshly inserted region.
      Specified by:
      insertUpdate in interface DocumentListener
      Parameters:
      e - the document event
    • removeUpdate

      public void removeUpdate(DocumentEvent e)
      Gives notification that a portion of the document has been removed. The range is given in terms of what the view last saw (that is, before updating sticky positions).
      Specified by:
      removeUpdate in interface DocumentListener
      Parameters:
      e - the document event
    • changedUpdate

      public void changedUpdate(DocumentEvent e)
      Gives notification that an attribute or set of attributes changed.
      Specified by:
      changedUpdate in interface DocumentListener
      Parameters:
      e - the document event