Article View: borland.public.jbuilder.java.swing
Article #1553Re: How to close a JDialog
From: Paul Furbacher TeamB
Date: Fri, 31 Oct 2003 13:25
Date: Fri, 31 Oct 2003 13:25
75 lines
3348 bytes
3348 bytes
In <3fa19f13$1@newsgroups.borland.com> Mynor Paredes wrote:
> The point is that the "Ok" and "Cancel" buttons are inside the jp_
> List panel.
Do you have control over the design of that panel?
If so, a better design would be to move those
buttons out of that panel. The panel should
concern itself just with presenting the data
germane to it, not controlling the environment
in which the panel is nested. Instead, the
dialog should own those two buttons: they are
dialog, not list panel, controls.
> How do I do to get the JDialog where the jp_List is
> contained, and then make the dispose?
If you have to have those buttons on that list panel,
add the ability to access them to the panel, and
then add ActionEvent listeners to them from the
dialog:
public class MyListPanel extends ... {
...
public JButton getOkButton() { return this.okButton; }
public JButton getCancelButton() { return this.cancelButton; }
...
}
public class MyDialog extends ... {
public MyDialog(...) {
try {
jbInit();
this.listPanel.getOkButton().addActionListener(
new ActionListener() {
public void actionPerformed(...) {
// handle OK action
}
}
);
// do the same with the cancel button.
}
catch (...) { ... }
}
}
Or, if you don't want to give direct access to the
buttons, you could just add methods to the MyListPanel
class which allow you to add listeners to those buttons
directly:
public class MyListPanel ... {
...
public void addActionListenerToOkButton(ActionListener l) { ... }
public void addActionListenerToCancelButton(ActionListener l) { ... }
...
}
But really, just move those buttons to where they
properly belong. Do things correctly from the outset
and you (and we?) will have less work to do.
Paul Furbacher [TeamB]
Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
Technical Details
Message-ID:
<20031031092557809-0500@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-han1.dfn.de!news-fra1.dfn.de!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fa1769a@newsgroups.borland.com> <3fa191d8@newsgroups.borland.com> <3fa19f13$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,9b06c5d510019547 X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-10-31 06:39:19 PST User-Agent: Halime (MacOSX)/1.0rc2b Newsgroups: borland.public.jbuilder.java.swing Message-ID: <20031031092557809-0500@newsgroups.borland.com> References: <3fa1769a@newsgroups.borland.com> <3fa191d8@newsgroups.borland.com> <3fa19f13$1@newsgroups.borland.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Subject: Re: How to close a JDialog From: Paul Furbacher [TeamB] <pfurbacher@mac.com> Organization: Reverse Alchemy, Inc. Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 68.39.103.120 Date: 31 Oct 2003 06:25:54 -0700 X-Trace: newsgroups.borland.com 1067610354 68.39.103.120 (31 Oct 2003 06:25:54 -0700) Lines: 75 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news-han1.dfn.de!news-fra1.dfn.de!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail