0

If the JTable's cells have an associated Renderer I am able to get the insets.

:
int x = ((JComponent)myRenderer).getInsets().left)
:
:
int x = ((JComponent)myRenderer).getInsets().right)
:

I have specific code to verify if the call from getCellRenderer() returns a null and it does. When this occurs I am uncertain how the Insets can be retrieved?

Unhandled Exception
  • 1,427
  • 14
  • 30
  • 1
    Why do you think you need the insets? What is the problem that you are trying to solve. Post your [SSCCE](http://sscce.org/) that demonstrates the problem. One line of code does not help. – camickr Jan 14 '15 at 20:39
  • Trying to calculate the true available space within a cell which will be used for other calculations. If the cell width is 50 but the left and right Insets are 5 each then the "true" cell with is 40 (not 50). – Unhandled Exception Jan 14 '15 at 21:06
  • Ok, so post your `SSCCE` that demonstrates the problem. If you set the Border properly as asked on your previous question, I don't see what the problem is. The default renderer uses a JLabel which does not have a Border. `When this occurs I am uncertain how the Insets can be retrieved?` Then the Insets will be 0. – camickr Jan 14 '15 at 21:21
  • Won't the size of the cell be determined by the `TableColumn`? You could also use the preferredSize of the cell renderer's component, which, if written correctly, will take into consideration the insets... – MadProgrammer Jan 14 '15 at 23:02
  • Thanks for the feedback. I will research more in depth shortly as I have a few things in the works to test out. I have a small sample, but it works (Arrrgggh...I hate when that happens). The actual application is doing something usual that I will have to track down. – Unhandled Exception Jan 15 '15 at 12:38

0 Answers0