Solved

Multiple table editors

Posted on 2004-08-30
14
220 Views
Last Modified: 2013-12-13
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
Comment
Question by:cathalmchale
  • 9
  • 3
  • 2
14 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 11931318
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
 
LVL 18

Expert Comment

by:armoghan
ID: 11931334
check this out as well.. This may be of some help
http://www.javaworld.com/javaworld/javatips/jw-javatip116.html
0
 
LVL 37

Accepted Solution

by:
zzynx earned 125 total points
ID: 11931341
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
 

Author Comment

by:cathalmchale
ID: 11949656
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
 
LVL 37

Expert Comment

by:zzynx
ID: 11949684
Use the SimpleDateFormat with EEEE as pattern
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 125 total points
ID: 11949701
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
 

Author Comment

by:cathalmchale
ID: 11950031
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 125 total points
ID: 11950079
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
 
LVL 37

Expert Comment

by:zzynx
ID: 11950118
Concerning the date picker:
Maybe you're interested in this discussion:
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20800000.html
0
 

Author Comment

by:cathalmchale
ID: 11950120
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
 
LVL 37

Expert Comment

by:zzynx
ID: 11950192
>> 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
 
LVL 37

Expert Comment

by:zzynx
ID: 11950199
>>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
 
LVL 37

Expert Comment

by:zzynx
ID: 11962047
Still questions left?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 11997367
Thank you :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I build my own IDE using ASP.NET MVC? 2 34
MySQL  on Tomcat 8 30
eclipse apache tomcat admin console 52 73
servlet example 17 12
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now