• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pass the selected value from a JTable to a textField of a running JFrame Form

 
Eder Suarez
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there!

I've tried lots of ways without success and I'm starting to lose my mind , i hope anyone have any ideas!

So here's what happens: I have a GUI(Entradas) that asks the user to fill in a form with textFields, a comboBox, etc. I have a specific non-editable textField with a button towards it. The button opens a new GUI(ResultadosNombre) with a JTable that get the list filled with MySQL data for the user to choose. Its supposed to get the selected field info and pass it to Entradas' textField. The thing is that i get no error at all but it doesn't set the textField's text. I tried validating and setting visible another instance of Entradas and it works but i lose the already input data and the past window remains open. I've also tried with validate(), repaint(), invalidate() - validate(), with no success

Here's my code for Entradas:



And here's ResultadosNombre's code:



Note: My code is not complete yet as it does nothing with the input data. I just want that thing to work lol.

I hope someone can put me in the right track and tell me what am I doing wrong, thanks!
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help a bit if you explained that you made the code in NetBeans GUI builder, because it doesn't make much sense otherwise.

You might be better off making your pop-up window a JDialog - see Darryl Burke's post here: http://www.coderanch.com/t/536130/GUI/java/Returning-value-pop-up-window .

As for why your code isn't working, I'm not sure, but you seem to be creating a new instance of ResultadosNombre when you press the button. This then creates its own instance of Entradas. So when it updates entradas, it's not the one that called it.

 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUI forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!