1

I have two radiobuttons(Say rbtn_Asia,rbtn_Europe)and one JTable. When I select rbtn_Asia, table must contains Asia's data. Similarly when I select rbtn_Europe, table must contains Europe's data. (Asia's data and Europe's data is in same database which will be updated periodically). I have implemented upto this.

My problem is like this: Consider the following case: I have selected rbtn_Asia and obviously table will contain Asia's data. Now let database has got two new tuples of Asia, how can I update the JTable dynamically without selecting the rbtn_Asia once again (because rbtn_Asia is already in selected state).

kleopatra
  • 51,061
  • 28
  • 99
  • 211
svkvvenky
  • 1,122
  • 1
  • 15
  • 21
  • what event do you want to use to update the data? If the radio button is already selected, then do you want to periodically update your table? Something should trigger the update..in the form of an update button or you should periodically poll the table to check. – sethu Mar 02 '12 at 07:39
  • Yes,If the radio buttons i already selected,the table should be updated whenever database is changed... – svkvvenky Mar 02 '12 at 07:49
  • 1
    Unless you have the ability to have the database tell you when it's changed, you'll have to have a background thread that polls the database periodically to see if it's changed. If it has, then just call the same handler as when the button is clicked. – Kylar Mar 02 '12 at 13:23

1 Answers1

2

In your button handler, update your implementation of TableModel, which should then fire the appropriate event. A structure that supports clear() such as Map, shown here, is convenient. More examples may be found here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045