Article View: borland.public.jbuilder.java.swing
Article #7535Re: Best way to show pop-up window?
From: Andy Lau
Date: Wed, 17 Jan 2001 10:42
Date: Wed, 17 Jan 2001 10:42
159 lines
6497 bytes
6497 bytes
Hello all,
I need some help to solve some dialog problem. thanks.
Basically I created a Login Dialog (modal dialog) box to validate
username and
password, and then pass the username/password to it's 'owner' frame for
database connection.
I have tried the DBPasswordPrompter and it works , however, I want to add
more features so I
created my own dialog box.
The main application has something like this:
public Application1() {
Frame1 frame = new Frame1();
Dialog_Login dialog = new Dialog_Login(frame,"try",true); // a
modal dialog
dialog.show();
frame.setUser( dialog.getUser());
frame.setPassword(dialog.getPassoword());
frame.loadframe();
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
And the main frame has something like:
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
// jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public void loadframe() {
try {
jbInit(); // I want to load the frame myself instead, instead at the
constructor.
}
catch(Exception e) {
e.printStackTrace();
}
}
The Dialog has something like:
public Dialog_Login(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
jbInit();
pack();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
Problem I face:
1) after the dialog exit ( or rather hide() ) , then the parent 'frame'
will show up.
However , it gave me some errors like :
See com.borland.dx.dataset.DataSetException error code: BASE+39
com.borland.dx.dataset.DataSetException: Operation cannot be performed on an
open DataSet. Close the DataSet first.
at com.borland.dx.dataset.DataSetException.c(Unknown Source)
at com.borland.dx.dataset.DataSetException.y(Unknown Source)
at com.borland.dx.dataset.StorageDataSet.s(Unknown Source)
at com.borland.dx.dataset.StorageDataSet.ac(Unknown Source)
at com.borland.dx.dataset.StorageDataSet.setColumns(Unknown Source)
at com.ids.spectrum.Frame1.jbInit(Frame1.java:3421)
at com.ids.spectrum.Frame1.loadframe(Frame1.java:761)
at com.ids.spectrum.Application1.<init>(Application1.java:39)
at com.ids.spectrum.Application1.main(Application1.java:69)
I am sure the main frame works as it was able to run properly if I disable
the dialog box.
As far as I know, when you say dialog.show() , the 'owner' frame will not
execute until
dialog.hide() which causes dialog.show() to return.
This mean that the application is running sequencially , and I am just
wondering
why will the Dialog box interfer with it's owner frame ????
The dialog box and it's owner frame both have their jbinit() method. They
are executed in a sequential manner.
Also, all my Database connection properties are initilased within the
jbinit() method of the 'owner' frame.
Your comment/help is greatly appreciated.
Andy.
hn McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
news:MPG.14cdb2b271adba45989e9c@forums.borland.com...
> On Mon, 15 Jan 2001 17:23:02 -0500, Steve Swett wrote:
>
> [snip]
> > What is the best way to do something like that? I'm pretty new
> > with Java, so I don't know whether I should be looking at a dialog,
> > option pane, or a card layout solution. (or something else)
>
> I assume what you mean by a CardLayout would be to switch the card on
> the frame to show the other information. Although that would not be
> hard to do, I would avoid that approach because I think the interface
> would be somewhat confusing to the user. Opening a dialog is more
> typical in that sort of a situation, so the user would understand it
> more readily.
>
> The difference between the dialog and option pane approaches are in the
> implementation, and they should achieve essentially the same thing.
> The JOptionPane class provides convenient methods for placing the
> buttons and showing your object in a dialog.
>
> If JOptionPane does what you want it to do, then it is probably the
> better approach, since it is a little easier. But if you want to do
> things that JOptionPane does not handle, then you will find yourself
> fighting it, and you would be better off using a JDialog.
>
> One example where JOptionPane does not work very well is if you need to
> validate some input and if it is invalid, display an error dialog and
> then allow the user to correct the problem. The problem there is that
> the JOptionPane showXxxxDialog() methods close the dialog before they
> give control back to the caller. In these cases, a JDialog works much
> better.
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
> http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<3a6576f8_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!202.79.104.39References:
<3a6377a0_2@dnews> <MPG.14cdb2b271adba45989e9c@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,267d9c3d9ca6f479 X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2001-01-17 02:44:03 PST Reply-To: "Andy Lau" <alau@idsfinance.com> From: "Andy Lau" <alau@idsfinance.com> Newsgroups: borland.public.jbuilder.java.swing References: <3a6377a0_2@dnews> <MPG.14cdb2b271adba45989e9c@forums.borland.com> Subject: Re: Best way to show pop-up window? Date: Wed, 17 Jan 2001 18:42:24 +0800 Lines: 163 Organization: ids X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 NNTP-Posting-Host: 202.79.104.39 Message-ID: <3a6576f8_2@dnews> X-Trace: 17 Jan 2001 02:42:00 -0800, 202.79.104.39 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!202.79.104.39