• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable and Bound Properties Question  RSS feed

 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Reader,
I am using JDK 1.6.0_29 on Windows.
I add a PropertyChangeListener to a JTable like so...

Here is MyPropChangeListener class...

During runtime, if I edit the value in one of the JTable cells, the property name "tableCellEditor" is displayed.
However, if I print out a list of all the bound properties for class javax.swing.JTable, "tableCellEditor" does not appear in the list.
I get the list as follows...

Can you explain this anomaly ?

Cheers,
Avi.
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never used the Introspector before, so I'm just guessing.

I'm guessing that the Introspector just looks for methods that follow the get/set/is method naming standard to identify a bean property.

This does not prevent the class from firing a PropertyChangeEvent for other events in the class.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The saying goes...
If you want something done right, do it yourself.

I added the following to method propertyChange in class MyPropChangeListener...

From the stack trace I saw that my propertyChange method is always invoked from method setCellEditor in class javax.swing.JTable.
So I looked at the source code for that method and found...

Note that cellEditor is a member variable of class javax.swing.JTable and indeed the property name "cellEditor" appears in the list of properties for class JTable that I obtained via the Introspector.
I would like to thank the JavaRanch community for their lack of response to my question which drove me to find the solution myself.
Just goes to show that laziness really is a sin ;-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!