File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes formatting challenge using JSpinner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "formatting challenge using JSpinner" Watch "formatting challenge using JSpinner" New topic
Author

formatting challenge using JSpinner

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi Guys,

I have a formatting challenge that I'm trying to rectify. I'm working with a JTable and a JSpinner class. I got the working code sample from http://forums.devshed.com/java-help-9/datepicker-inside-a-jtable-536152.html. I decided I wanted to use it, but it needs some formatting issues worked out. Basically I'm trying to ensure that a Date field in JTable always displays via format "MM/dd/yyyy". I'm working with two classes which you can see below. I tried setting up a couple more methods that perform some formatting for me, but it meant changing the Date type to a String type, and well, it just messed things up. As you look at the lines of code that have been commented out, you can probably see what I was trying to do.

As it stands now, when the JTable first loads the data, it is formatted in the cell using some ugly default Date format. I want it to display always in the format "MM/dd/yyyy". When I click on the date cell the JSpinner certainly does display in the proper format dictated in the constructor of DateCellEditor. Then after editing and the cell loses focus, that ugly default date format shows up again. Could someone please show me what it is I need to do to retain the format I want for this date cell? I'm a bit lost on this one.

Alan

Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

Concepts: Editors and Renderers


luck, db
There are no new questions, but there may be new answers.
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Thanks for the link to the tutorial. That helped.

Alan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: formatting challenge using JSpinner