Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get a value from another frame with applets?

Status
Not open for further replies.

Petal

Programmer
Jun 8, 2001
56
NO
I have one applet where i can save and delete some data.

When one item is selected and the "delete" button i pressed, i open a new frame/window with a dialogbox where the user is asked " Are you sure you want to delete the current record?". Then the user can click on either yes or no. When the button is clicked i set the boolen "save" to true/false.

The problem is to get this value to the main applet..

i have tried made the function

boolean getAnswer() {
return save;
}

in the dialogapplet dialogBox
and tried with this function in the main applet
dialogBox box = new dialogBox(new Frame);
System.out.println(box.getAnswer);

the problem is that it looks like that box.getAnswer is reviced before I have clicked yes or no.. and therefore it always are set as false.

How do i make the main applet wait to get the value to i have closed the dialog window?


Jørn Arild Andenæs
 
Well, you could use the JOptionPane class since it has static methods to do just this via dialog boxes. Or, you need to have the Dialog Box send a message to the main applet via a callback reference once it has received the response via an action listener.

If you need a specific example, email me, I'll write one up for you.

Regards,

Charles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top