JDK1.5 table cell editor behavior has changed, help
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Shawn_Castrianni
Posted On:   Friday, March 11, 2005 09:29 AM

I am trying to achieve Excel editing behavior in a JTable. I had everything working in JDK1.4 and then it broke when going to JDK1.5. Apparently, the JDK has changed slightly. The particular Excel behavior that is broken is when double clicking a cell to start editing. The cell editor is a JTextField. In JDK1.4, double clicking the cell would start the edit process causing my JTextField cell editor to get shown and the JDK would forward the MouseEvent with a click count of 1 to the JTextField. The JTextField would respond to the MouseEvent with click count of 1 and just position the text cursor as desired. This is just like Excel. Now in JDK1.5 with no other code changes, the double click starts the edit process and the MouseEvent is forwarded    More>>

I am trying to achieve Excel editing behavior in a JTable. I had everything working in JDK1.4 and then it broke when going to JDK1.5. Apparently, the JDK has changed slightly. The particular Excel behavior that is broken is when double clicking a cell to start editing. The cell editor is a JTextField. In JDK1.4, double clicking the cell would start the edit process causing my JTextField cell editor to get shown and the JDK would forward the MouseEvent with a click count of 1 to the JTextField. The JTextField would respond to the MouseEvent with click count of 1 and just position the text cursor as desired. This is just like Excel.



Now in JDK1.5 with no other code changes, the double click starts the edit process and the MouseEvent is forwarded to the JTextField BUT this time with a click count of 2. The JTextField responds to this MouseEvent with click count of 2 by highlighting whatever text is in the JTextField. I don't want this initial highlight to take place. Any work arounds I can do? I can't change the click count back to 1 in the MouseEvent because there is no setter for click count.

   <<Less
About | Sitemap | Contact