Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parent/Child Window Communication

 
Lang Miao
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Background: I have a parent window (JFrame object) CustomerForm and a child window (JFrame object) InsertForm. InsertForm is displayed when insert button on CustomerForm is clicked.

Question:
1. When InsertForm is displayed, how can I make CustomerForm not accessible? Previously I use setFocusableWindowState( false ) but that only makes CustomerForm stays behind InsertForm; the buttons on CustomerForm are still clickable.

2. How do I pass info on InsertForm to CustomerForm? I have text fields of Name, Address, etc. Do I just use getText() and pass the values to CustomerForm's variable?

Thanks in advance
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>1. When InsertForm is displayed, how can I make CustomerForm not accessible?

when InsertForm is created, next line = CustomerForm.setVisible(false);
in the constructor of InsertForm, have

2. How do I pass info on InsertForm to CustomerForm?
either make InsertForm an inner class (exposing the variables to InsertForm)
or pass a reference to CustomerForm when InsertForm is created


then, in the window closing event you add the code to update CustomerForm data
 
Lang Miao
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding your solution #1
The CustomerForm, then, will be hidden. I just want to deactive it. User still sees it but can't bring it on top or press any buttons on it
I come up with this one. Let me know if this sufficient.


Thanks a bunch for the previous reply. Solution #2 works great.
[ October 22, 2004: Message edited by: Lang Miao ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / AWT / SWT / JFace forum...
[ October 23, 2004: Message edited by: Dirk Schreckmann ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic