Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing data between JDialogs  RSS feed

 
Marcel C S Vieira
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody !

I'm trying to implemente the following:

- In a LoginDialog, I have a btOKActionPerformed wich performs a validator method (login/password).

If isValid() --> RecebeDialog.setVisible(true).

It's working fine. My concern is about displaying the login's name validated in a loginLabel located in RecebeDialog.

If I made myself clear about this, I ask for your help because I've already tried unsuccessfully and exhaustively to do so.

Here's the full code for whom wants to execute:

(check line 28 to 33)



Now, the RecebeDialog class:

(ckeck line 8 and 12 to 17)



Thanks in advance.
 
Andrey Kozhanov
Ranch Hand
Posts: 79
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at line 13 of your RecebeDialog class. There you create new instance of LoginDialog class, and of course in new instance of LoginDialog class txtLogin field will be empty.

There are several ways of fixing the problem. For example, create new constructor in RecebeDialog, which will take login name as parameter, and call it in line 23 of LoginDialog. Or make LoginDialog Singleton, so the only instance of this dialog will contain the only instance of login name. Or create the third class, which will store login name, and to the same instance of which both dialogs will have access. In this case LoginDialog puts login name into this third class and RecebeDialog takes it from this class.
 
Marcel C S Vieira
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrey Kozhanov wrote:Look at line 13 of your RecebeDialog class. There you create new instance of LoginDialog class, and of course in new instance of LoginDialog class txtLogin field will be empty.

There are several ways of fixing the problem. For example, create new constructor in RecebeDialog, which will take login name as parameter, and call it in line 23 of LoginDialog. Or make LoginDialog Singleton, so the only instance of this dialog will contain the only instance of login name. Or create the third class, which will store login name, and to the same instance of which both dialogs will have access. In this case LoginDialog puts login name into this third class and RecebeDialog takes it from this class.


I've made it !! Thanks to you, Andrey !!
I've been struggling with this for about 2 weeks !
Man, I really appreciate your help ! Thanks a lot !!
I would like to shake your hands in gratitude. Or
God bless you.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!