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
  • @mKorbel could i email you my project, and help me implement your solution. my email address is frandave.free@gmail.com – Francis Oct 24 '12 at 13:50
  • @Java_Francis sorry not, I'm going there for my enjoy and pleasure, please to delete this comment – mKorbel Oct 24 '12 at 13:59
  • 1
    @Java_Francis if you want someone doing your work for you consider hiring a consultant (and pay her/him, of course ;-) – kleopatra Oct 24 '12 at 14:52
  • am just stuck with that idea, but thanks anyways i came up with a new way to accomplish my task – Francis Oct 24 '12 at 17:24
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