Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing data between JFrame & JDialog  RSS feed

 
Roshni Singhania
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here's the situation and what I've done so far - I have a JFrame in my program, which is instantiating a JDialog. Each of the two contain a JTextField. When I type in the JDialog's JTextField and press Enter, its text should be passed to JFrame's JTextField. I have tried to solve this in 2 ways. The code that I've written is as follows -



I basically want to wait on JDialog's input before doing further processing. Could someone please advice me as to which one of the above ways is ok? These 2 are the ones I've done so far. Any other ways/suggestions are highly appreciated.

Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> When I type in the JDialog's JTextField and press Enter, its text should be passed to JFrame's JTextField.

if you set both textfields to share the same document, no need to press enter
 
Roshni Singhania
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I didn't know much about the document of the textfield. So I looked it up after reading your reply. It solved my problem. Thanks you very much. You helped a lot.



Originally posted by Michael Dunn:
> When I type in the JDialog's JTextField and press Enter, its text should be passed to JFrame's JTextField.

if you set both textfields to share the same document, no need to press enter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!