Guys...I am writing a program in Java which includes writing different panels where i need to pass values from one panel to another.
i.e I have got a combo box to choose a title and i need to get the performances for that title in my next panel. So can anyone of you please help me to short this problem.
thanx..

Recommended Answers

All 10 Replies

Lets assume you have two classes, Panel1 and Panel2. You could have a method called updateFromComboBox in Panel1's class. Then, when the combo box in Panel2 is selected, you can use the updateFromComboBox method to update Panel1 based on whatever was selected in Panel2. Note that this would require that in Panel2's constructor, you have passed in an Object of type Panel1 (that way you can call the updateFromComboBox) method.

For future reference, the quickest way to not get help is to put "URGENT" in a thread title.

Hey....
I've got two panels, a film panel where i select a title of that film and then second panel is performance where i print out the performances for the film selected in my film panel.
So how do U think i should put this.

Yehh..thanx for dat advice...will keep dat in mind next time i write somethinn

lol

commented: "lol" indeed. -4

Do you want the second panel to be open all the time, or do you want it to appear when the user selects a film in the first panel?

Yehh..thanx for dat advice...will keep dat in mind next time i write somethinn

The advice I gave you applies in any situation where you want to share information from one class with another class. That includes GUIs. So. . that advice should be useful to you right now.

James...
the second panel comes up when the user select a film and clicks next.
So I somehow have to save the title of the film selected from the first panel and use it in the second one.Can u help me figure this out.
I think i have to write a action listener for the select button but have no idea how to do it.

Have an update method in the class of the panel you want to show the title in. The class of the other panel should have a reference to the one where you want to show the title. Then call the update method, passing the information in, or using the update method to get the information.

Nobody is going to write this code for you.

James...
the second panel comes up when the user select a film and clicks next.
So I somehow have to save the title of the film selected from the first panel and use it in the second one.Can u help me figure this out.
I think i have to write a action listener for the select button but have no idea how to do it.

You need to look up how to write a listener; the web is full of tutorials and samples, so nobody's going to write another one for you! Google.
You should write a constructor for your second panel that takes the film (or its title) as a parameter and in that constructor you can populate the panel with the right data.
In your listener you can query the currently selected film and then call the second panel's constructor to create a new instance with the right data.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.