Click to See Complete Forum and Search --> : Implementing a Dialog


Mehdi
March 17th, 1999, 12:33 AM
How to implement a Dialog when a user clicks on a menu item in order to confirm his action ? My class extends the Frame class and I have to an instance of the Frame class to the Dialog class. When I click on the menu item, an exception occurs:"null parent frame".


Thanks in advance.

Mehdi

thiru
March 17th, 1999, 02:37 AM
Hi mehdi,


Here is the code for ur question:

// OpenDialog is the name of the menuitem

// this is a inner class within ur class derived from frame

class SymAction implements java.awt.event.ActionListener

{

public void actionPerformed(java.awt.event.ActionEvent event)

{

Object object = event.getSource();

if (object == OpenDilaog)

OpenDilaog_Action(event);

}

}


void OpenDilaog_Action(java.awt.event.ActionEvent event)

{

// to do: code goes here.

// this refers to the frame

// the class u derived from Frame

Dialog d = new Dialog(this,"Ur Dialog",true);

// try using setSize if needed.

d.resize(100,100);

d.show();

}


// for any further details contact me at psthiru@wipsys.soft.net