aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes why JButton and not others such as JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "why JButton and not others such as JTable" Watch "why JButton and not others such as JTable" New topic
Author

why JButton and not others such as JTable

budsy remo
Ranch Hand

Joined: Sep 20, 2008
Posts: 103
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

Joined: Oct 27, 2005
Posts: 19720
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: why JButton and not others such as JTable