473,326 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

jdialog dispose not works properly

Hi Guys,

I have a small application which i wrote in Java. There is a MainFrame extends jfram class. There is another class named LoginDialog extends JDialog.

My MainFrame class have main method where i create object of my Dialog class before i do setVisible(true) for MainFrame.

I just want that Login Dialog appears first and if user get authentication from System then it show MainFrame window.

LoginDialog appears and when i press ok login button i check authentication and then if its true, i set a localvariable true then setVisible(false) so that LoginDialog disappears. And now i check in Mainframe for the localvariable of LoginDialog either its true or false.

During debugg mode it show true and then i also calls my MainFrame but during run mode it does not works.

I dont knw whats wrong here.?? Can any body helps me??

here is code.

MainFrame Class code....
[HTML]
public static void main(String[] args) {

MainFrame aWindow= new MainFrame ();
Toolkit thekit=aWindow.getToolkit();
Dimension winsize=thekit.getScreenSize();
aWindow.setBounds(winsize.width/3,winsize.height/4,winsize.width/3,winsize.height/3);
aWindow.setDefaultCloseOperation(EXIT_ON_CLOSE);
aWindow.setLocationRelativeTo(null);
aWindow.setMaximumSize(new java.awt.Dimension(400, 325));
aWindow.setAlwaysOnTop(true);

aWindow.loginChecked = aWindow.login();
//aWindow.setVisible(true);
if(aWindow.login()){

aWindow.setVisible(true);
}

else if(!aWindow.tillNotLoged ) {
System.out.println("Sorry");
aWindow.dispose();

}


}

private boolean login() {

LoginDlg login = new LoginDlg(this);
if(LoginDlg.loggedIn){

return true;
}
return false;

}
[/HTML]
Code from LoginDialog class
[HTML]
public static boolean loggedIn = false;

private void jLoginBtnMouseClicked(MouseEvent evt) {
System.out.println("jLoginBtn.mouseClicked, event=" + evt);
this.setLoggedIn(true);
//this.dispose();
this.setVisible(false);

}


public void setLoggedIn(boolean loggedIn) {
this.loggedIn = loggedIn;
}

[/HTML]

is there any way it should work by disposing dialog but still have class data members. As much i know dispose only clear GUI Elements (Panel, buttons, frams etc) from Memory and all other class functions are still in hand. Atleast in .Net it works.

I need your urgent help.

Thanks
best regards
Sep 25 '07 #1
3 7196
JosAH
11,448 Expert 8TB
Why don't you simply add an ActionListener to that 'OK' button and close the
JDialog from within that ActionListener's actionPerformed method? Note that
when you dispose a JDialog, the entire object stays intact, it just becomes
invisible.

kind regards,

Jos
Sep 25 '07 #2
Why don't you simply add an ActionListener to that 'OK' button and close the
JDialog from within that ActionListener's actionPerformed method? Note that
when you dispose a JDialog, the entire object stays intact, it just becomes
invisible.

kind regards,

Jos

Thanks Man,

I am actually using a GUI Plugin named Jigglo. I just used there provided Event. I did not understand when i debugg program it works prefect but when i run it, it does not work. I am using Eclipse as IDE.

What could be a reason for this problem.???

Ok i gonna try it with Action Performed.

Best regards
Sep 26 '07 #3
JosAH
11,448 Expert 8TB
Ok i gonna try it with Action Performed.
Yes you should; those MouseEvents are really low level events and you don't
want to deal with those; you want to handle the 'semantic' or higher level events
such as ActionEvents fired by e.g. buttons; the button took care of the low level
event and offers you a higher level event (an ActionEvent). Use those instead.

kind regards,

Jos
Sep 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
6
by: TB | last post by:
I understand the basics of finalization and implementing IDisposable and how one is guaranteed access to managed objects only when working through the IDisposable interface. My question is to what...
15
by: Sam Sungshik Kong | last post by:
Hello! A disposable object's Dispose() method can be called either explicitly by the programmer or implicitly during finalization. If you call Dispose, the unmanaged resources are released...
6
by: Teresa | last post by:
1) If I do want to keep an object alive throughout the live of an application, how can I ensure that the GC doesn't clean it up? 2a) How do I determine if an object is a managed or an unmanged...
5
by: Markus Stoeger | last post by:
Hi, I have a class similar to that: class MyClass : IDisposable { IDisposable obj1; IDisposable obj2; IDisposable obj3; MyClass() {
5
by: Michael.Suarez | last post by:
Suppose I have a button on a form that opens up another form. the code in the buttons click event is: frmMyCustomForm frm = new frmMyCustomForm (); frm.ShowDialog(); frm.Dispose(); The...
2
by: Seanus | last post by:
Hi all, I've got a little problem with the JDialogs. Housekeeping: I'm on windows xp, with the latest JRE, I'm getting no error as such. Basically, I've got some JDialogs in my program (are...
9
by: aleplgr | last post by:
Hello, in this code suppose that the dlg is defined in one case as a JDialog, I run it and it seems that the JDialog is executed AFTER closing it, so the message is printed after closing the JDialog....
1
by: sibusiso | last post by:
HI Can anyone help with the scenario where where you have to pass a certain data from one JFrame to another. For example, suppose you have a JFrame is your main window you disabled your Jmenu...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.