File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Getting data from one frame into another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Getting data from one frame into another" Watch "Getting data from one frame into another" New topic

Getting data from one frame into another

Raj Moti

Joined: Nov 14, 2004
Posts: 4

I am having a frame say frame1 which is having a button and textfield.
On clicking a button which is on that frame1 I am displaying a frame say
frame2. Inside that frame2 I am having a text field and a button.
What I want is that when I will click on button of frame2
whatever there in the textfield of frame2 should get displayed in textfield
which is inside frame1.

With anticipatory thanks
Kriti Garg
Ranch Hand

Joined: Sep 13, 2004
Posts: 50

pass your first frame refrence to ur second frame and create a get/set
methods in ur first frame,call these on action listener of second frame


int count = container.getComponentCount();//frame1 component count
for (int q = 0; q < count; q++) {
if (container.getComponent(q)instanceof JTextField) {
String text= ((JTextField) container.getComponent(q)).getText;

set this text to frame 2 text field



I agree. Here's the link:
subject: Getting data from one frame into another
It's not a secret anymore!