• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing data between JDialogs

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 79
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic