Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Facilitating excel-type text overrun in JTable  RSS feed

 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody have an idea how to get a JTable to allow text to flow to the right over empty cells ala Excel? As a starting point, can anybody offer an explanation of the method JTable uses to draw its labels? I'm afraid this borders on the impossible, but....
Thanks
 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, for future generations, here's a start:
In my class extending JTable, I created a boolean isPainting and set it to false. Then in the repaint method, I set it to true, call super.repaint and set it back to false.

In the JTable, I overrode getCellRect() so if it isPainting it computes the cellRect based on the fontMetrics of the textfield the JTable uses for editing cells, and the number of empty cells to the left (I mean right--the other left) of the cell in question.
This works, but the vertical lines in the table still show through. It seems wierd since in BasicTableUI, the lines are painted before the cells are, so I would expect them to get painted over, where appropriate.
HTH, somebody someday!
e
[This message has been edited by eric moon (edited April 20, 2001).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It helped me today, because your question had me scratching my head. Nice solution.
 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you actually try it, you will discover there are some nasty redrawing problems.... It may be a challenge to get this working right.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!