[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Multiple table editors

Hi how could i solve the following?

There is a JTable for adding dates to:
FROM...            TO...
from date 1       to date 1
from date 2       to date 2
etc.

the dates can be relative or fixed, eg:
today less 5 days at 12:00
or
17-07-2004 @ 12:45

So i think the editor could prove problems, my idea
                     relative selected     *other selected           @time
ComboBox         ComboBox             Text field to             Standard date
-----------          ------------              enter days less        editing formatted
Relative             Today                    value                      text field or JSpinner
Fixed                 less 1 day
                         less 2 day
                         other*

but if fixed is selected then we just have a standard date editing spinner
So the editor is dynamic depending on there choices - is this going to get complicated/require multiple editors etc.?
Any knowledge with similar designs would be greatly appreciated,
Thanks.
-----------
0
cathalmchale
Asked:
cathalmchale
  • 9
  • 3
  • 2
3 Solutions
 
armoghanCommented:
One way of doing it is hiding a column and then showing the column of your choice.. That will definately work

Other way could be of changing the editor but I think that you may need to reconstruct the table if you need to change the Table editors..

And if you need to know how multiple columns can have multiple cell editors
check this out
http://www.javaworld.com/javaworld/javatips/jw-javatip102.html
0
 
armoghanCommented:
check this out as well.. This may be of some help
http://www.javaworld.com/javaworld/javatips/jw-javatip116.html
0
 
zzynxSoftware engineerCommented:
Rough idea:

Date picker      Combo       Edit field    Combo            Time picker
--------------      --------        -----------    ---------            --------------
own design      minus                          days                2 text fields (for hours & minutes) + spinners
                        plus                             weeks
                                                            months
                                                            ...

So,

today less 5 days at 12:00 =   today                minus   5   days   12:00
17-07-2004 @ 12:45           =  17-07-2004       minus   0   days   12:45


so in fact, if the edit field is 0 it is fixed, otherwise relative.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
cathalmchaleAuthor Commented:
Hi ya, thanks for the help so far.

I want to make a combo box of daysOfWeek and i want them to be in current locale - simple, but was looking at the Date and Calendar classes to find a method like

public String giveMeTheDay( MONDAY )

but cant find it!!  perhaps its just too early in the morning, but how do i do this???
0
 
zzynxSoftware engineerCommented:
Use the SimpleDateFormat with EEEE as pattern
0
 
zzynxSoftware engineerCommented:
So,

You have the constructor:

SimpleDateFormat(String pattern)
          Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the default locale.

and also

SimpleDateFormat(String pattern, Locale locale)
          Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the given locale.


Give this a try:

SimpleDateFormat fmt = new SimpleDateFormat("EEEE");
Date d = new Date(); // today
String dayName = fmt.format(d);  // Will give you "Wednesday" if you locale uses the English language

So if you feed it with 7 consequtive dates, you'll have all 7 day names
0
 
cathalmchaleAuthor Commented:
OK cool ;-)
also what do you think is the best component for the user to edit a fixed date or time?
a JSpinner or formatted text field can be a little clumsy and require a lot of validation - or do you think these are the best components to be used??
0
 
zzynxSoftware engineerCommented:
For the time I use
- an hour field + a JSpinner
- an minutes field + a JSpinner

For the date I use my own written Date picker based on the source found at http://www.geocities.com/mschliesman/prog_datechooser.htm
0
 
zzynxSoftware engineerCommented:
Concerning the date picker:
Maybe you're interested in this discussion:
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20800000.html
0
 
cathalmchaleAuthor Commented:
thanks date chooser looks nice.
Hour field and min field have seperate spinners??  and this looks ok??  and you label them hours: mins: or would a ':' between the 2 make it obvious??  what do u think? :)
0
 
zzynxSoftware engineerCommented:
>> Hour field and min field have seperate spinners??  
Yes.
>>and this looks ok??
According to my taste, yes ;°)

>>and you label them hours: mins: or would a ':' between the 2 make it obvious??
I just have them all on one line wihthout anything added.
Of course the corresponding label "Start Date:", "Start Time:" or whatever label make it clear for the user he can give in a date, date + time or just a time.
0
 
zzynxSoftware engineerCommented:
>>Thanks date chooser looks nice
But it has some bugs that have to be fixed. (look at the EE link I gave you for some more info)
0
 
zzynxSoftware engineerCommented:
Still questions left?
0
 
zzynxSoftware engineerCommented:
Thank you :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now