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 design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "GUI design " Watch "GUI design " New topic
Author

GUI design

Maksym Odintsov
Greenhorn

Joined: Jan 22, 2009
Posts: 11
Hi. I have the following requirement on my GUI :
It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.

I designed GUI in such a way :

JTextField that holds name
JTextField that holds location
search button

If both fields are blank than pressing the search button will give you all the records, if one is blank and another is not then it will give you only the records that match the filed that is not blank, and if both fields are not blank that the result will be all the records that match both fields.
But there can be one more way, when both fields are not blank pressing search can give all records that match to one field and records that match to another(name or location fields exactly match values specified by the user).

Do I need to provide this way ? And if I do what is the better way to do it ?
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2247

My GUI has 3 radio buttons: Name AND Location, Name OR Location and All Records.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Anne Crace
Ranch Hand

Joined: Aug 29, 2005
Posts: 223
Mine has 2 combo boxes, each populated from the file, and each with "any" added to the list. The "any" is the default value for each. "Any" and "any" returns all records. A name and a location can be specified or a name and "any" or a location and "any". There are lots of ways to implement your GUI.


SCJP, SCJD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4911
    
  10

Anne Crace wrote:Mine has 2 combo boxes, each populated from the file, and each with "any" added to the list. The "any" is the default value for each. "Any" and "any" returns all records. A name and a location can be specified or a name and "any" or a location and "any". There are lots of ways to implement your GUI.

So you have no support to search for name or location ?


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Mahesh Kumaraguru
Ranch Hand

Joined: Jun 01, 2005
Posts: 95
Anne Crace wrote:Mine has 2 combo boxes, each populated from the file, and each with "any" added to the list. The "any" is the default value for each.


How would you distinguish between "Any" the default and a location called "Any" ?
Kevin Florish
Ranch Hand

Joined: Jan 06, 2009
Posts: 163
My approach is the same as Anne using the 2 combo boxes.

I populate with "---ANY---".

If there's a city with this name I'd sure like to go there


Java5 Tutorials | Java6 Tutorials | HTML/CSS Tutorials | JavaScript and jQuery Tutorials
Anne Crace
Ranch Hand

Joined: Aug 29, 2005
Posts: 223
Roel De Nijs wrote:
So you have no support to search for name or location ?

Name and "any" matches name only.
Location and "any" matches location only.
From my instructions: 'It must allow the user to search the data for all records ("any", "any"), or where the name and/or location fields exactly match values specified by the user. The above situations take care of the "or". Choosing a specific value under both name and location takes care of the "and".
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4911
    
  10

Hi Anne,

my instructions are the same, but it all depends in how you interprete the or. My interpretation was if user selects name = "Hilton" + location = "Paris" and chooses to or the criteria, then user will get a list with all hilton-hotels and all hotels in Paris.

but your approach keeps the gui more simple and user friendly, so i'll implement a similar search-function.

Kind regards,
Roel
Anne Crace
Ranch Hand

Joined: Aug 29, 2005
Posts: 223
The "simple" aspect is why I chose this approach. I got the idea from the red Exam Cram book (Alain Trottier is the author - not sure of this). He suggested it as sparing the user from his/her own typos. The combo boxes are populated from the database, so they are an exact match and spelled correctly. Matching regular expressions to me are just cryptic and ugly in any language. I've had to use them in javascript and it is done the same way as it is in Java. I really didn't enjoy it too much. I'm sure I will have to do it again
Alecsandru Cocarla
Ranch Hand

Joined: Feb 29, 2008
Posts: 158
Anne Crace wrote:Matching regular expressions to me are just cryptic and ugly in any language.

But they are very powerful and useful, if used correctly.

I had two textfields, and for each textfield a checkbox ("All" - or "any", in your case). Checkbox selected -> text field disabled. I also had a separate checkbox "only bookable".


SCJP 1.4 100%
SCJD 99.5%
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4911
    
  10

Anne Crace wrote:He suggested it as sparing the user from his/her own typos. The combo boxes are populated from the database, so they are an exact match and spelled correctly.


Agree. I guess you load the content of those comboboxes when application starts. But did you also handle the possibility to reload the content of those combos?
Anne Crace
Ranch Hand

Joined: Aug 29, 2005
Posts: 223
Roel De Nijs wrote:
Agree. I guess you load the content of those comboboxes when application starts. But did you also handle the possibility to reload the content of those combos?

Since you brought it up, I need to give more thought to that. Currently, if a record is booked (write CSR number to owner field), the record still shows up in the table with the owner field populated with the number. My GUI won't allow it to be overwritten, however. The items still show up in the Combo boxes, too. I haven't checked the delete situation. That one should NOT show up in the table, and should not show up in the Combo boxes either. I suppose I have more work to do on my Combo Box Model and its listeners. I'm sure it is doable as there are several remove() methods in the various box models.
Kevin Florish
Ranch Hand

Joined: Jan 06, 2009
Posts: 163
Hi Anne

I adopted the same approach as you and looked into the delete/insert and updating of the combo boxes.

I couldn't see a way that you could signal the combo box if say for instance a user in another application decides to delete a record using the DBAcess
interface method.

I suppose you could implement an observer to let the combo box know but then it all starts getting complicated.

The only other way I could find was to update the combo box on any key press in the gui, which seems terribly inefficient.

I then plumped for refreshing the combo boxes when the user presses the "SearchAll" button which in my gui resets both combo boxes to show
"---ANY---".

I used a cache to hold my contractor records so this isn't such an I/O hit.

I am sure there's a more elegant solution, but at this stage of the project I was knackered

Cheers Kevin
Anne Crace
Ranch Hand

Joined: Aug 29, 2005
Posts: 223
Kevin Florish wrote:

I then plumped for refreshing the combo boxes when the user presses the "SearchAll" button which in my gui resets both combo boxes to show
"---ANY---".
I am opting for the "Reserve" button for the removal. I do call refresh() from my Search button. Not sure if it works, though. I haven't really tested this part of the functionality yet. I am flummoxed right now, too. I am not going to bother with it any more over the weekend. Maybe the answer will come to me in my sleep.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4911
    
  10

if you have combo boxes with a list of possible names and locations where the user can choose from, you won't expect to find no records at all. so when a search result in no records at all, you inform the user that the search data may be out of date and that a refresh will take place.

The only problem with this approach is: if a new hotel is added, user can't search on it. so maybe a menu option to refresh combo's should also be added.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI design
 
Similar Threads
B&S: GUI and Search functionality
Searching Criteria - GUI
Doubt in specification of GUI for URLyBird 1.1.2
B&S Searching
Exactly match searching in URLYBird