Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why JButton and not others such as JTable

 
budsy remo
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question :
i was studying the mvc architecture of swings and saw that when it comes to JButton we never call the model to change the contents(such as actionCommand) instead we call the setActionCommand()
and in the source code i saw that it looks something like this :



now whenever we deal with Jslider or JTables then we always do changes in the model by calling the models and explicitly do changes in the model . We could have come up with similar code for sliders as well ? Why didn't we ?
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSpinner has all the methods SpinnerModel has. JTable has all the methods TableModel has apart from addTableModelListener and removeTableModelListener.

You are right that JTable has no methods for adding rows. That's because the TableModel interface doesn't require implementing classes to support it; you could have an implementation with a fixed number of rows and columns. Changing the value of a cell is possible through the JTable though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic