Question

I want to resize an image inside a JGoodies form layout according to the size the cell has, i.e. so that the image fits perfectly in the cell. If I understand correctly, there is no real component for the cell, the size is known only implicitly by the layout manager, right? Any ideas?

Was it helpful?

Solution

As suggested by kleopatra I found this solution: The image is put inside a scrollPane and I get the viewable size of the cell by

javax.swing.JComponent.getVisibleRect().getWidth();

where the JPanel is a JComponent... I can't paste more code directly, as we use other frameworks that wrap Swing and I didn't test that directly, sorry. If somebody else has this problem and uses this solution please add low level Swing code, thanks.

Thanks for your suggestions!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top