File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes GUI Questions: JTable and ComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "GUI Questions: JTable and ComboBox" Watch "GUI Questions: JTable and ComboBox" New topic
Author

GUI Questions: JTable and ComboBox

Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
Friends,
May I ask your opinion on the these 2 points.
Do I need to:
1. Provide sorting capability to the JTabel, which might be specially useful for queries that return larger results?
2. Restrict the user to the origins and destinations available in the db.db by means of uneditable JComboBox?
or should I let the user enter whatever search string he/she wants in editable JComboBox or JTextField?
Thank you very much in advance!
+Seid


Seid Myadiyev<br />SCJP, SCWCD, SCBCD, SCEA-Part 1
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Seid Myadiyev:
Friends,
May I ask your opinion on the these 2 points.
Do I need to:
1. Provide sorting capability to the JTabel, which might be specially useful for queries that return larger results?
2. Restrict the user to the origins and destinations available in the db.db by means of uneditable JComboBox?
or should I let the user enter whatever search string he/she wants in editable JComboBox or JTextField?
Thank you very much in advance!
+Seid

the answer to both is NO, because I dont see a "need to" regarding anything around the GUI, except that you "need to" provide a fairly user friendly interface.
now if the question started "do I want to", i might have answered maybe to #1, its a nice to have and most people do not provide sorting but you certainly wont lose points for implementing it, and might score some extras for doing so.
as for #2, I use an uneditable combo box, but I dont see any harm in your other options.
frank sun
Ranch Hand

Joined: Apr 11, 2003
Posts: 102
So, If I just put 2 textfields for the user to type in the criteria, will that lose score?
Appreciate!
Frank
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by frank sun:
So, If I just put 2 textfields for the user to type in the criteria, will that lose score?
Appreciate!
Frank

I'm not the assessor that marks your assignment, so I cant answer that question
Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
Do I refresh the JComboBoxes every time I access db.db. I am asking this becasue what if at some point the remote database gets renewed and some flight gets removed from the file.
Or should I not bother about this situation?
Thanks,
+Seid
Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
Hi.
Originally posted by frank sun:
So, If I just put 2 textfields for the user to type in the criteria, will that lose score?
Appreciate!
Frank

I've read here about people that has lost points on the GUI by using text fields instead of combo boxes.
Miguel
frank sun
Ranch Hand

Joined: Apr 11, 2003
Posts: 102
That makes no sense
Frank
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11481
    
  94

Hi everyone,

Frank So, If I just put 2 textfields for the user to type in the criteria, will that lose score?
Miguel: I've read here about people that has lost points on the GUI by using text fields instead of combo boxes.
Frank: That makes no sense

It doesnt make much sense, but I agree with Miguel: I also remember reading about people loosing marks, and they either believed, or got comments back, indicating that it was because of the lack of Combo boxes.
My instructions state that the user should be able to select the origin and destination of flights.
(highlighting is mine).
Depends how you read "select" - I choose to believe that I can select from a combo box. I have nothing to select in a text field.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
Thank you everyone for your input. My next question is how often do I update JComboBox for origin and destination.
Just once at the program start-up, or every time I access the remote db server?
I personally feel that it has to be more than just once after the program starts. But if the remote db file will never be replaced by the new one during the time the remote clients are running -- then there is no need for that. What do you think?
Thank you,
+Seid
Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
Thank you everyone for your input. My next question is how often do I update JComboBox for origin and destination.
Just once at the program start-up, or every time I access the remote db server?
I personally feel that it has to be more than just once after the program starts. But if the remote db file will never be replaced by the new one during the time the remote clients are running -- then there is no need for that. What do you think?
Thank you,
+Seid
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Seid Myadiyev:
Thank you everyone for your input. My next question is how often do I update JComboBox for origin and destination.
Just once at the program start-up, or every time I access the remote db server?
I personally feel that it has to be more than just once after the program starts. But if the remote db file will never be replaced by the new one during the time the remote clients are running -- then there is no need for that. What do you think?
Thank you,
+Seid

maybe you're going about this the wrong way, perhaps consider populating the Combo box with values that are already in the table, that way its always relevant, and theres no need to query the database for data you already have
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11481
    
  94

Hi Seid,
I used the following statment from the instruction to justify why I never update the JComboBox:

It is not necessary to provide for live updates on multiple clients when new bookings are made at other clients.

I just made a comment in my design decisions document that I was deliberately not updating the combo boxes.
Regards, Andrew
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11481
    
  94

Hi TQ,
maybe you're going about this the wrong way, perhaps consider populating the Combo box with values that are already in the table, that way its always relevant, and theres no need to query the database for data you already have

That could be problematic. You would have to look at the data you received back and at the criteria you have specified before you could update anything.
If you specify that you only want flights departing from SFO, then the table is only going to have the "SFO" value in the departure column - if you update the JComboBox with this, the user could never change to another location.
So you would have to check that the user still has "all" selected before you could update based on column 'x'.
Is it really worth this sort of effort?
Regards, Andrew
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Andrew Monkhouse:
Hi TQ,

That could be problematic. You would have to look at the data you received back and at the criteria you have specified before you could update anything.
If you specify that you only want flights departing from SFO, then the table is only going to have the "SFO" value in the departure column - if you update the JComboBox with this, the user could never change to another location.
So you would have to check that the user still has "all" selected before you could update based on column 'x'.
Is it really worth this sort of effort?
Regards, Andrew

ouch, I typed without looking at what I actually did, and thats what I thought I did but its sorta half of what I did.
sorry, let me explain, I dont updated the combo box either, but when it initially starts I use what I got from my initial search and dont run a seperate query, which is definately what I should do because I limit my initial search to 100 results, and this will pose a problem if there are more than 100 results, I would only provide search options for the first 100 that I got, boy am I glad this came up, because I did this over a month ago and haven't given it any more thought at all, and didn't consider the search when I implemented the limit on initial search
Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
Thank you, all, very much!
I got a clearer picture now!
Thanks again,
+Seid
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Andrew, if I did switch to using whats in the table after every search, but always included the wildcard (ALL) so the user can widen the search at any time, wouldn't that be better?
its not much code at all
Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
TQ,
1. Are you describing "Search Within Results"?
2. What if my initial query returns more than 100 -- do I not populate my JComboBox by them all and only a subset of them?
Thanks,
+Seid
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Seid Myadiyev:
TQ,
1. Are you describing "Search Within Results"?
2. What if my initial query returns more than 100 -- do I not populate my JComboBox by them all and only a subset of them?
Thanks,
+Seid

Seid,
1. not really, although it may appear to the user to be that way, and I suppose to some extent it really is, but the query goes to the database and not to whats in the JTable, only the combo box gets its values from the table model.
now if the Combo box only displays whats currently in the JTable, and provides the ANY search, then its basically switching between what appears to be a search within the results and therefore narrowing, but also able to widen.
2. Thats exactly what I'm having to reconsider now, but I think the way I have it with small changes will do, because if I settle with refreshing based on whats in the table, then the user always has the freedom to fetch all with no limits on how many it fetches, so the Combo box may initially display the first 100 names/locations, but as soon as the user fetches all it refreshes to display all, and I think this will work well, but should certainly be documented so the user is aware that the initial options may or may not be all his options, just as I've documented that the initial table is only the first 100 if more exist, so its up to the user how big his result is, and the GUI doesn't take a long time to load 2000 results on startup.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11481
    
  94

Hi TQ,
Do you have an option on your selection screen to limit the numbr of results you get back?
I don't like your approach, as you need to get all the results at some point to ensure your combo boxes are fully populated (if there are 1 million records?), and the end user may not be aware that they do not have all the options.
Note: this does not mean that your approach is wrong (and in fact, your approach is closer to the specs than mine ) it just means what I said: I dont like it.
One thing you should consider is to warn the end user if they do get 200 results in their initial screen ... tell them that the result set was limited, and that the combo boxes may not have all options. This does cause a problem though ... do you have a default option set in your combo box? If so, then they will be confused (it says "all", but I havent got all ???).
Even with warning the end user, what can they do if they suspect that they don't have the full set of data? Do they select "all" in every category (and go and make coffee for the entire office while they wait for all the potential records to arrive and be processed), or do they use their expert knowledge of the database to try and guess at what combinations might gve them the missing option (gee, I can't see ABQ in my destinations, but I think SpeedyAir fly there, so I will select all origins and destinations for PromptAir ... nope, better try PromptAir ... ahhh there it is).
My personal preference (and the way I have coded) is to add an extra method to the Data class that will return all the unique values for a given column. This means that the processing is done on the server where it belongs. If FBNS later upgrade to a real database, there would be no problem retrofitting this functionality, and the client would not even have to change.
This has gone outside requirements, but I feel the alternative is a very bad solution.
Regards, Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI Questions: JTable and ComboBox