This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes CONFUSED ... Isn't JList more appropriate than JTable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "CONFUSED ... Isn Watch "CONFUSED ... Isn New topic

CONFUSED ... Isn't JList more appropriate than JTable?

Richard Walter

Joined: May 26, 2001
Posts: 22
Hi coders,
Im confused about the GUI for FBN. Isn't JList more appropriate than JTable. The way I see it, the user searchs for a particular flight. Matching flights are return as a list(JLIst) of flights. The user clicks on the flight he is interested in, which gives more specific information about the flight and an option to enter number of seats and book flight.
Where does the JTAble fit into this? How are people using JTAble in their GUI design? Do you edit a 'no. of seats' cell directly to book a flight?
Richard Walter
Mike Wiegand

Joined: May 30, 2001
Posts: 15
the JTable is used to display the result set. An action listener needs to be attached to the ListModel of the JTable to process list selection events. Once a list selection event is fired, the event handler needs to determine which row was selected, then display details for that row. The number of seats to book text field may be part of the row detail which is displayed every time the row selection changes.
Gennady Shapiro
Ranch Hand

Joined: Sep 25, 2001
Posts: 196
The spec says JTable. Unless you want some points deducted you'd better use JTable.
I kinda see where they are going with this too. JTable is more flexible where it comes to column-based data. For example, you (on user request) may want to extend the JTable so that it shows Number Of Seat in different color, or use an a Warning icon if departure time is approaching, or edit some fields later on , or simply re-arrange columns for better viewing, stuff like that. JList is a simplistic approach to this problem.
But again, it would be a matter of your choice if the spec had not explicitely stated to use JTable.
Hope this helps.
[This message has been edited by Gennady Shapiro (edited October 31, 2001).]
Richard Walter

Joined: May 26, 2001
Posts: 22
Thanks guys for answering.
Its starting to make a little more sense. If I have understood correctly the JTable is more customizable but you are treating it like a list, where the user selects a row which is associated with a particular flight. There is no modification of individual cells, Am I right here?
I presume when a row is selected from the JTable, a dialog window pops-up (or, alternatively is displayed in another view on the main GUI) which allows the number of seats to book to be entered.
Dave McCarthy

Joined: Jun 12, 2001
Posts: 23
This is how I did my gui, comments would be great...
I have to combo boxes which are populate with the data from the database, with the "any" word added as the first choice. Upon startup I display all of the database record (which at the moment isn't a problem because there are only 24 records). I made my combo boxes "active" so to speak, in that I don't have to click any search button. If I changed the origin combo box, just the orgins in my jtable change. I then just placed a textfield to take the number of desired seats and "book" button immediately above my jtable, and have a pop-up window displaying the success or failure of booking. I did things this way to reduce the amount of mouse clicking by the user.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Hey Dave, it sounds like you stole my GUI. Actually my drop downs aren't active and the number of seats to book and the book button is underneath my JTable.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Dave McCarthy

Joined: Jun 12, 2001
Posts: 23

Just noticed some talk of using a gui builder such like the one you would find with IDE's such as Jbuilder. I've been using jbuilder for my programming, but I did not use it to create my gui. I was looking more for clean, easy functionality than something fancy with a lot of bells and whistles. The project specifications say we "may" use and IDE but there musn't be any residual dependencies because of it. I kept my button on the top as to centralize mouse movment/clicking as much as posible.I was also thinking of reducing clicking even more by not even having pop-up windows, instead have just a label with the "status" and the success/failure messages. Anyone who has already passed the project aspect of the certification have any comment on this?

I agree. Here's the link:
subject: CONFUSED ... Isn't JList more appropriate than JTable?
It's not a secret anymore!