aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Update Data between Frames Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Update Data between Frames" Watch "Update Data between Frames" New topic
Author

Update Data between Frames

Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
Hi, i can't figure it out how to solve this, the thing is that i have a Frame_A with a JList in it, then another frame: frame_B with a couple of textFields, i call the frame_B from the frame_A, i fill the textFields and the i need to click a Save button and insert the content of the textfields in the Jlist of frame A. Any Ideas.
[ April 25, 2008: Message edited by: Jorge Bend ]
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Hi, i can't figure it out how to solve this, the thing is that i have a Frame_A with a JList in it, then another frame: frame_B with a couple of textFields, i call the frame_B from the frame_A, i fill the textFields and the i need to click a Save button and insert the content of the textfields in the Jlist of frame A. Any Ideas.


1) Are these JFrames and are you using JTextFields? I'm just making sure that you're not mixing Swing and AWT components.
2) Consider using a JDialog or JOptionPane for your second "frame". It just seems to me to be a more natural fit here, plus you can make it modal or not if need be.
3) There are many ways to answer this. Remember that class A and class B are like any other classes despite their being inherited from Swing components. They can have private variables with public getters and setters and all that. One way to solve this is to have a public methods in class B that gets your data, say getStringA and getStringB. When the object of class B is done doing its thing, the object of class A can then call B's public methods to get this data. Here is a very simplistic example that uses a JOptionPane:

ClassA.java


ClassB.java

[ April 25, 2008: Message edited by: pete stein ]
Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
Great answer, was really helpfull!, I'm getting there..., another thing is that actually, there are 2 textFields and 1 comboBox in that JPane,after filling the info, I put all the text of these components together in a String variable and then return it to the frame A, put this incoming String in an Array and then have to pass it to a Jlist, setListData(myVar); but the JList it's not showing the text..
Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
wait now it's solved.. great help Thank!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Update Data between Frames