Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update Data between Frames

 
Jorge Bendahan
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wait now it's solved.. great help Thank!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic