AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

OO question

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.misc
View previous topic :: View next topic  
Author Message
Radu
Guest





PostPosted: Tue Feb 14, 2006 8:12 am    Post subject: OO question Reply with quote



Hi .

I have a program X.

In public class X, in main, I have something like

myFrame frame=new myFrame();
.....


In class myFrame extends JFrame, in the constructor "public myFrame()", I
have
.......
//Add panel to frame:
myPanel panel=new myPanel();
add(panel);

//Add a window events listener
addWindowListener(new WindowEventsListener());
.....


In class myPanel I implemented the isDirty property and an accessor,
getDirtyState. In WindowEventsListener, upon closing, I'd like to check the
isDirty property of myPanel.

My problem is that in WindowEventsListener I cannot say

public void windowClosing(WindowEvent e)
{
JOptionPane pane = new JOptionPane();
Toolkit.getDefaultToolkit().beep();
if (getDirtyState()==true)
{
if (pane.showConfirmDialog(e.getComponent(),"Save before quitting
?", "Program X", JOptionPane.YES_NO_OPTION)==0)
{
//The user chose YES
pane.showMessageDialog(e.getComponent(), "Save here - todo !", "Program
X",
JOptionPane.OK_OPTION);
System.exit(0);
}
else
System.exit(0);
}
}

because getDirtyState refers to myPanel, and I don't see myPanel from there.

Which is the proper OO way of passing this value all the way to my
WindowEventsListener, please ? The isDirty belongs in myPanel, not in
myFrame, and, either way, how would I pass that value to class
WindowEventsListener which extends WindowAdapter ?


Thank you, Alex.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.