Rob Camick wrote:
3 weeks ago you got multiple answers/suggestions to your original question.
Yet you didn't respond to either reply and now you expect more help even though you still haven't posted a reasonable SSCCE?
Three weeks ago I gave up on Swing.
A friend talked me into trying Python ttk which before long I was jumping through even worse hoops.
I then looked into other frontend frameworks. But it seems as if all the new ones build the pages on the server side and then ship all that info over the network. Not what I want
And so I came back to Swing.
Your question is about using a custom Date editor:
At first, I was able to reproduce the problem without using a table and so that made it simple. Which is why my original post was not about a table cell editor. However, as I implemented yours and Caseys suggestions, the simple one worked but not the table one so that made things more complicated. So then the only way to reproduce the problem was in a table and a simple example no longer was going to cut it. Which I did state this in a previous post. Maybe you missed that one.
BTW, the cell editor I have is pretty much the one you helped me with on another question. So the code I have came from you. You, being Rob. And that code worked fine other than the one extra character with the + and -. that was until I added the Mask and added your binding code rather than the keylistener. Once I added both those, that is when the editor no longer stopped or cancelled itself when you exited the edit. It actually stayed on the screen when I clicked another tab for a different form. Its as if the Mask and the new action binding are fighting each other. or something is missing.
Sadly, this question has evolved. I was actually closing out this question because for the scope of the original question we somewhat answered it as a stand alone field editor. I was actually thinking of posting a new question with the editor in a table. I am planning on looking at Robs last posted code to see what is different from this one verses the one he gave me in a previous question and if it still does not work, then I will attempt an SSCCE I hope even Rob will be okay with.
As for Caseys Code, I tested it. The Mask part didnt work. I endered 010223 and instead of filling in the date it just inserted the date. Once I hand put in the date the + and minus worked. however, when I left the field and came back in and pressed the - key I got a BadLocationException: Invalid Remove. And of course, Rob claimed I needed to use Bindings and yours uses a document listener. If your had of worked. I would have gladly replaced Robs example.
javax.swing.text.BadLocationException: Invalid remove
at javax.swing.text.AbstractDocument.handleRemove(AbstractDocument.java:605)
at javax.swing.text.AbstractDocument.remove(AbstractDocument.java:590)
at LocalDateDocListener99.handleInsert(SwingLocalDateTest99.java:307)
at LocalDateDocListener99.lambda$insertUpdate$0(SwingLocalDateTest99.java:271)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
So lets just end this question.