This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 19655
    
  18

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why JButton and not others such as JTable
 
Similar Threads
How do you get the JButton name
actionCommand
getActionCommand
Which JPanel is the button on
JTree: strange appearance / broken tree