Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Dynamic GUI for Booking System

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,

I was googling my questions and came to JavaRanch, answers were very satisfying and friendly so wanted to give a shot! =)

I need to implement a GUI for a flight agency, which takes the flight details(passenger, plane type, destination, seats etc.) from an input file, and then open a second GUI for booking; if there are 40 seats, the booking GUI will be with seats(buttons) and seat names "1A Window", "1C Aisle" and so on, if there are 20 seats the booking GUI will be of course smaller, if there are 100 seats it will be of course bigger. Each seat needs to store passenger information if it is booked, and shall not be booked if it is already booked.As you can imagine 40 seats plane booking GUI could be 5cm and 80 seats GUI could be 10cm, how shall I arrange this size, or maybe I make a fixed size and then add the scrolling option for bigger sizes?

I built before with the help of Eclipse plugin "Window Builder" a static GUI, I just go to the button and then fill in the Actionlistener with my desired functions, wasn't challenging. But I cant build a dynamic GUI with Eclipse Window Builder and later I dont know how to add my desired functions into automatically created buttons, lets say with a for loop.

Second problem is the input file, for choosing the file I can use JFileChooser API but then shall it be a text file?How would I assign the values from the input file to the attributes in my classes?I am using eclipse Indigo.Lets say there are 10 passengers with name, age, credit card etc. in the input file, how can they be set to the objects...

I am very lost in the beginning but if I can find a way to start and have something, I can later improve it or go in the direction of improving it... I appreciate your time and help!
Posts: 1104
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Boznan,
Welcome to the Ranch!

Bozan Kocaman wrote:
I was googling my questions and came to JavaRanch, answers were very satisfying and friendly so wanted to give a shot! =)

Sure, we like to talk and yes, JavaRanch is cool

As you want to build a GUI dynamically, you simply have to get rid of the GUI builder and do it yourself via code. You should start with understanding the layouts. Let me point you out to the tutorial

You might look to build your GUI with say a GridLayout and add components in a loop. This way, you will be able to control the number of components.
Alternatively, you can look at building a JTable (without the header) and control the number of columns/rows dynamically.

Either way, what you are attempting is complex. If you haven't worked with layouts before, I suggest that you take a step back, get comfortable with layouts before you attempt this.

As for the input file, have you considered XML or JSON format to store the various details in the file? That way you could be able to take advantage of the various APIs available to parse XML and JSON content.
    Bookmark Topic Watch Topic
  • New Topic