0

I have a Jtable with editable fields and a Jbutton. I want my button to be disabled until all table fields are filled. After all fields are filled I want the button to be enabled. How can I achieve this?

Thanks for the help.

Alptugay
  • 1,676
  • 4
  • 22
  • 29

1 Answers1

3

two options:

  • implement a TableModelListener which checks if the condition is met, and if so enabled/disables the button
  • implement a custom TableModel which does the check itself and fires a PropertyChange if not/filled. Listen to that property and enable/disable as appropriate

The latter is the better option, because it's really up to the model to decide about its own state.

kleopatra
  • 51,061
  • 28
  • 99
  • 211