0

I have one tab that displays the list of users in a JTable that I have extracted from a database and another tab that displays JTextFields that want to edit the user details then save them to the database.

One of the unique feature of a user is a userID(Integer) that am able to get from the JTable depending on which row is selected.

Now I want use that userID and fill the JTextFields with data from the database to allow editing and hence save the new values below is the UI( can't post images)

Basically is how to share the Integer variable between the two tabs

Francis
  • 603
  • 1
  • 6
  • 17

2 Answers2

3
Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
1

You need to have your own mechanism for communication between the tabs. For instance you can have a reference of second tab in first tab so that when row is selected in table you can call specific method in second component. If you want to decouple them you can add a listener interface which second component implements and adds itself as listener to first one and so on.

Ashwinee K Jha
  • 9,187
  • 2
  • 25
  • 19