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(fals e) 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.setBoun ds(winsize.widt h/3,winsize.heigh t/4,winsize.width/3,winsize.heigh t/3);
aWindow.setDefa ultCloseOperati on(EXIT_ON_CLOS E);
aWindow.setLoca tionRelativeTo( null);
aWindow.setMaxi mumSize(new java.awt.Dimens ion(400, 325));
aWindow.setAlwa ysOnTop(true);
aWindow.loginCh ecked = aWindow.login() ;
//aWindow.setVisi ble(true);
if(aWindow.logi n()){
aWindow.setVisi ble(true);
}
else if(!aWindow.til lNotLoged ) {
System.out.prin tln("Sorry");
aWindow.dispose ();
}
}
private boolean login() {
LoginDlg login = new LoginDlg(this);
if(LoginDlg.log gedIn){
return true;
}
return false;
}
[/HTML]
Code from LoginDialog class
[HTML]
public static boolean loggedIn = false;
private void jLoginBtnMouseC licked(MouseEve nt evt) {
System.out.prin tln("jLoginBtn. mouseClicked, event=" + evt);
this.setLoggedI n(true);
//this.dispose();
this.setVisible (false);
}
public void setLoggedIn(boo lean 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
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(fals e) 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.setBoun ds(winsize.widt h/3,winsize.heigh t/4,winsize.width/3,winsize.heigh t/3);
aWindow.setDefa ultCloseOperati on(EXIT_ON_CLOS E);
aWindow.setLoca tionRelativeTo( null);
aWindow.setMaxi mumSize(new java.awt.Dimens ion(400, 325));
aWindow.setAlwa ysOnTop(true);
aWindow.loginCh ecked = aWindow.login() ;
//aWindow.setVisi ble(true);
if(aWindow.logi n()){
aWindow.setVisi ble(true);
}
else if(!aWindow.til lNotLoged ) {
System.out.prin tln("Sorry");
aWindow.dispose ();
}
}
private boolean login() {
LoginDlg login = new LoginDlg(this);
if(LoginDlg.log gedIn){
return true;
}
return false;
}
[/HTML]
Code from LoginDialog class
[HTML]
public static boolean loggedIn = false;
private void jLoginBtnMouseC licked(MouseEve nt evt) {
System.out.prin tln("jLoginBtn. mouseClicked, event=" + evt);
this.setLoggedI n(true);
//this.dispose();
this.setVisible (false);
}
public void setLoggedIn(boo lean 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
Comment