|
-
March 17th, 1999, 01:33 AM
#1
Implementing a Dialog
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
-
March 17th, 1999, 03:37 AM
#2
Re: Implementing a Dialog
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 [email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|