I am working on a swing application that retrives the details of flights that take off on a particular date and span of time.I want to limit my JTextFields(that diplays the flight name) & Jbutton that retrieves details based on the no of flights retrieved.Can any Swingers help me Swing thro this
The application looks somewhat like this. A.There is a Flight Plan page that takes in the date and route of flights. B.The next page retrieves the names Flight id/nums that are flying ont tht date at that time from the DB.Now, this is where i need the dynamic textfields and buttons, ie, I want to limi the tf's and but's to the number of flights retrieved.That is 10 Flights 10 tf's ,20 -20 and so on dynamically. TextField ------>Flight Id/Name Button------>(named details)to retieve details from the DB.
Ok, I think I understand what you are trying to do... I'll start with some rough psuedocode and see if that helps you understand. (This is just how I would do it, and there are many different ways it can be done)
The actual code for dynamically creating buttons is not too hard... do the buttons need listeners?
The loop will look something like this:
Now, to create the panel, you just need a loop to extract the elements. Depending on which version of Java that you have, you will have to cast the button back when you want to add it to your panel or frame, ie: myPanel.add((JButton)flightNumbers.get(i) myPanel.add((JLabel)flightTimes.get(i)
Does that get you going a little?
[ April 28, 2005: Message edited by: C. Alan ] [ April 28, 2005: Message edited by: C. Alan ]
Hi Narahari, I would suggest you to use a GridLayout for the couples JTextField/JButton. Once you retrieve how many flight/textfield/buttons you need, you can create a grid that will contain all the textfields and buttons you need. If you need to update the entire thing in a second moment, you can still remove the components in the panel where you put the grid and redo the same thing.