Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know this relates to a really old problem, however, it caused me some problems too. As <a href="https://stackoverflow.com/users/203657/kleopatra">kleopatra</a> responded in a comment above, I solved the problem with a <code>JFormattedTextField</code>. However, the solution requires a bit more work, but is neater.</p> <p>The <code>JFormattedTextField</code> doesn't by default trigger a property change after every text changes in the field. The default constructor of <code>JFormattedTextField</code> does not create a formatter.</p> <p>However, to do what the OP suggested, you need to use a formatter which will invoke the <code>commitEdit()</code> method after each valid edit of the field. The <code>commitEdit()</code> method is what triggers the property change from what I can see and without the formatter, this is triggered by default on a focus change or when the enter key is pressed. </p> <p>See <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html#value" rel="nofollow noreferrer">http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html#value</a> for more details.</p> <p>Create a default formatter (<code>DefaultFormatter</code>) object to be passed to the <code>JFormattedTextField</code> either via its constructor or a setter method. One method of the default formatter is <code>setCommitsOnValidEdit(boolean commit)</code>, which sets the formatter to trigger the <code>commitEdit()</code> method every time the text is changed. This can then be picked up using a <code>PropertyChangeListener</code> and the <code>propertyChange()</code> method.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload