• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JTable/GUI Questions

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps for this assignment, or perhaps just for fun and instruction, I would like to find out how to do some things with JTable that I haven't been able to figure out. Keep in mind I am quite new to JFC/Swing and am just learning it for the first time in the context of the Developer assignment.
I was thinking about having a 'Book Flight' button on every row listing the flights on the main screen of the app. Clicking on that button would bring up a dialog box where the user would enter information to book the flight he/she selected.
Another, more general, question I've got is what is the 'standard' or generally accepted idea for doing form transitions in a Swing application. An example of what I mean is you have say a main screen (eg. shows the flights available), and from there you fo to the booking screen, and from there you may go back to the flight screen or to some sort of confirmation screen. Using tools like Access or just with HTML, the practice for doing this is well established. But I am not sure what one is supposed to do in Swing...
Either generic code example illustrating how one should implement these kinds of features, or simply a good reference to a book that goes into that kind of thing would be helpful (note I do have Core Java Volume II, but it does not seem to go into enough detail for my tastes).
Thanks,
Vlad
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vlad,
On the principle of reducing keystrokes to a minimum, and thus lessening the chances of bad data, I set up a JTable that updates the JComboBox of the flight for which the user wishes to book seats. I have all the panels up at the same time. Just some ideas to get you going...
 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Vlad
Having buttons on every row appears to be a good idea, but maybe it may make the JTable look slightly cluttered.
I have kept a single button for booking below the JTable in the main frame. This button becomes enabled as soon as the user selects a row of the JTable. Clicking the book button brings up a Dialog box which displays the details of selected flight, and asks user the number of seats to book. This dialog box also has a panel to show the result of the operation. The dialog box remains open till the request is completely processed and its result displayed.
In fact the user can submit concurrent requests- for eg. the user click book button which brings up DialogA and then user submits the request. Even while DialogA is open the user can click the book button again to bring up DialogB and submit another request. Both DialogA and DialogB will know the results of their respective requests because they attach themselves as listeners to the RequestJob objects they create- one for each request.
However I am not sure whether I should have a book button, or should I have the booking functionality in a menu and toolbar. I think a menu and toolbar are more appropriate for the main window.
The combo boxes containing the criteria to search for flights are on the main window on top of the JTable- It seems more intuitive since the former immediately controls the contents of the latter.
What do you think of my design?
 
vladimir levin
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Rahul Rathore wrote:
>Having buttons on every row appears to be a good idea, but
>maybe it may make the JTable look slightly cluttered.
I find that if the button is somewhat smaller than the width
of the row, it seems to look fairly good. I like the idea that
the user needs to click once to book a flight rather than
click, move mouse, click again. I have not seen any examples
where a JButton is placed into a JTable on each row. Is it hard
to do? The alternative, as you've described it is certainly
adequate... I just thought it would be nice to try putting the
button each row.
>I have kept a single button for booking below the JTable in the
>main frame. This button becomes enabled as soon as the user
>selects a row of the JTable. Clicking the book button brings
>up a Dialog box which displays the details of selected flight,
>and asks user the number of seats to book. This dialog box
>also has a panel to show the result of the operation. The
>dialog box remains open till the request is completely
>processed and its result displayed.
This seems good... That's the way I plan to do it too, with a
dialog box. May I ask how you implement a dialog? Is it using
a JDialog object or something else?
>However I am not sure whether I should have a book button, or >should I have the booking functionality in a menu and toolbar. >I think a menu and toolbar are more appropriate for the main >window.
I think a button is just fine. A toolbar pretty much is a button
anyway, but I think in this case a simple button is enough.
A menu doesn't seem as straightforward, and I personally don't
like that idea very much. My Human-Computer Interaction
prof. in Uni. always suggested to keep things as simple as
possible for the user.
>The combo boxes containing the criteria to search for flights
>are on the main window on top of the JTable- It seems more
>intuitive since the former immediately controls the contents of
>the latter.
That seems perfectly adequate and standard, and also how I plan
to do it.
Vlad
 
reply
    Bookmark Topic Watch Topic
  • New Topic