Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

formatting challenge using JSpinner

 
Alan Shiers
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Concepts: Editors and Renderers
 
Alan Shiers
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link to the tutorial. That helped.

Alan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic