Michelle Nicholes

Ranch Hand
+ Follow
since Sep 22, 2011
Michelle likes ...
Netbeans IDE C++ Java
Merit badge: grant badges
Biography
Been coding since I was 17.  My first company I coded in Pascal in DOS.  Second Company wrote custom business apps using Paradox also in DOS.  Windows killed that company.  Learned Java and Swing in College.  Third Company wrote custom business apps using J2EE EJBs and Flex for front end.  The end of Flash killed that company.  After that, I worked for DOD companies using C and VHDL.  Now I am in my 60's and tinkering with business apps again in Java and using Swing of all things. 
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
19
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michelle Nicholes

I have a JTree with a TreeModel implementation.

I am not displaying the root node so the tree starts off showing the root node expanded and all the root nodes children.

The problem is when I add a new child, the new child does not show in the tree view.

I did some research on this and found a claim that this is a known bug for Jtree.  

I am definitely seeing this so maybe its true.

Does anyone know of a work around to get the tree to update the tree view to show the new Child of the Root Node?
4 months ago
I did finally find the solution.  When I was doing my cell ComboBox to get it to work we used this type of class definition:



However, for some reason when I did the same thing for the Formatted Text Field it didnt work.



If you google JFormattedTextField and TableCellEditor you only get two good results.  Both are using this format:



And you let the Cell Editor manage all the other methods.  and as far as I can tell, it now works.  I have no idea why the first way I did it didnt work but it seemed as if somehow it lost reference to the Mask Formatter and the second way seems to have maintained it.  So the first way works great with Combo Boxes and the second way with FormattedTextFields.  Hope this crazy thread helps someone one day.  
5 months ago

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.
5 months ago

Rob Camick wrote:


Did you use "Increment Date" in both cases to only use one name in the action list or was that a mistake?

Also, when I put this in my Cell Editor which implements TableCellEditor, the fireEdditingCancel or Stop doesnt seem to be working any longer.  Do you think this way of capturing the + and - is interfering with the TableCellEditor Parent?

5 months ago
okay, I have tried to make this as small as I could and still reproduce somewhat the environment I am actually using.
If I dont have it right, give me some credit for trying













I hope I got it all.  Some of this code is in production so I really didnt want to change it and it didnt make sense to make a copy.  Notice it works the first time.  but when you click the next field and then click back it puts the + or - in but when you exit it gets rid of it.  but having it in is janky.
5 months ago
The SSCCE does not implement or test the problem I am trying to overcome.  using the + key to increment dates and - to decrement dates.  I added the Mask to prevent the + or - from being appended to the end of the date.  That was the issue to begin with.  The problem I now have is it only works the first time.  Not the second time.  And I am using this field as an inline editor for a JTable and so to post an SSCCE would require quite a bit of code to illustrate what is actually happening.  When I first posted the test code it was happening there but now that I have added the mask its not happening the test code.  I guess I will have to create a small app to illustrate it.
5 months ago
After further testing, I discovered this only works the first time.  It fails once you leave the editor and return to the editor.  I know your going to complain that I never mentioned an editor.  That was because I would have had to put an entire table in the test code and I thought you would have complained about that.
5 months ago
5 months ago
I ended up adding a MaskFormatter and that solved the problem.  However, I need to look into what Rob said regarding using KeyBinding instead of KeyListener.  BTW, I thought you wanted an SSCE that you could copy and paste into an editor and it ran to illustrate the problem.  Which is what I did.  I am finding it extremely difficult to please you.  But there are people you can never ask the question right and you will never please them.  I am not trying to offend you but... Cant you give a forced retired 60 year old a break.
5 months ago
You statement is incorrect for what I asked.  The demo in the link you provided is not displaying the percentage with the percent symbol and allowing you to enter without the symbol as I stated in my question.  So no, its not working as I asked.
6 months ago
There was no reply here, it was just me adding more info.  Would someone look into this one?
6 months ago
I want to increment my date with + key and I want to decrement date with - key.  Similar to Quicken.
I am getting the date to increment and decrement but the character is still being placed in the textfield which obviously I dont want.  I googled, one person suggested a documentListener but I couldnt figure out how to get the key event and abandoned that one.  Another suggestion was doing some kind of filter but his listener was nothing like mine so I was quite confused on how to try what was being suggested.  

Focus on the Date Field for this post.
6 months ago
So I am tinkering with JFormattedTextField.
I have a test case which does Rates, Dollars, and Dates
They display the Data as desired.
However, when it comes to entering the data, it seems to require I enter the special chars for it to accept my input this is not desired.  When I google it, I get lots of posts on how to format how it looks but found nothing on the topic of modifying how you enter data.

I have data already entered at startup.
Edit any of the fields and clear the field
then enter just the numbers
for instance for the rate enter .2 and hit enter.
it does not accept it

or in the Dollar field
Type only 100.00
again, does not accept it.  

its like you must type in $100.00 for it to accept it.  Which is not what I want.

Hopefully someone here has delt with this and can point me in the right direction.

6 months ago
6 months ago
I have a Filter ComboBox.  when I clear the search text it only shows one row instead of, in this case four rows.

Now I have a way to fix it by setting the popup visible to false and then showing the popup again but this seems inefficient.  Is there a better way?

Filter Code:




Model:

6 months ago