Solved

Multiple table editors

Posted on 2004-08-30
14
221 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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
 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Options in Zimbra Server 2 54
even odd program using while loop 3 41
tomcat startup error 5 65
Running JavaFX on JDeveloper 12C 1 32
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

809 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