File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

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

Joined: Oct 27, 2005
Posts: 20271

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: why JButton and not others such as JTable
It's not a secret anymore!