Solved

Multiple table editors

Posted on 2004-08-30
14
218 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Use the SimpleDateFormat with EEEE as pattern
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 125 total points
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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
Comment Utility
>>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
Comment Utility
Still questions left?
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Thank you :)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

762 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

6 Experts available now in Live!

Get 1:1 Help Now