• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BookingFieldListener

 
Mario Zott
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to everyone,
My GUI is almost done, but I have one question about handling the ENABLE state of the booking button. I created 2 JTextFields (Flightnr, seatsToBook), but the bookButton should only be enabled, if both field contain some text. So i created the following class:

is this a "good way" to handle this ...?
pleased to get some suggestions...
thanx mario
 
Ben Ritchie
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did it differently - a flight is selected by clicking on a row in the table, and I use a JSpinner for the number of seats to book. Each time a new row is selected the spinner limits are set so that 1 <= number to book <= available seats. If the flight is full then the spinner and the book button are disabled. This means you can never try and book seats that are not available.
 
Mario Zott
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds nice (actually this is how I had it before), until the following thought came into my mind: what about booking a flight without selecting it from the table - usually the person who operates the booking - keeps some high recomended flightNr's in mind, - so he/she enters the flightNr and some seats, and presses the bookbutton... (by the way JSpinner was the only class i used from the 1.4 api - so i decided to give all machines with < 1.4 version a chance to run my application )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic