SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Check out how TableCellRenderers work. By default, for Icon, it returns a JLabel that contains the image. I'm sure you can use that to your advantage.
Mike Lipay wrote:
Rob Prime wrote:Check out how TableCellRenderers work. By default, for Icon, it returns a JLabel that contains the image. I'm sure you can use that to your advantage.
If I knew how to resize and image, it might. I have been looking at the renderers and haven't seen anything about sizing an image.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:
2) Sub class a JLabel and override its paintComponent to draw the image. It's a bit unconventional though.
luck, db
There are no new questions, but there may be new answers.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Isn't that the same as option 3 - a custom Icon implementation?
luck, db
There are no new questions, but there may be new answers.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:Try using ImageIO#read(URL) instead of Toolkit to load the images.
Rob Prime wrote:Not with this little information. You should post an SSCCE that includes at least the following:
- the creation of the table model
- the creation of the JTable and its renderers / editors
- a main method![]()
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:That's not an SSCCE. There is now too much code; I don't need all those labels, the dialog, etc. And there is no main method like I asked you.
Rob Prime wrote:I see two images just as I expected. I did change the name of the file to remove the space and dashes, as these were not in the file when I saved it from this thread. If I change the name in the code so it doesn't match anymore then I see a blank cell like you described. So my guess is that your physical file name and the file name in the code don't match.
Mike Lipay wrote:
Darryl Burke wrote:Try using ImageIO#read(URL) instead of Toolkit to load the images.
That can't be done inside the table, it requires IOException to be caught.
Mike Lipay wrote:Rob,
I took your code, compiled and executed it, and the image shows. There must be something different between your code and mine that makes mine not work.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:
Mike Lipay wrote:Rob,
I took your code, compiled and executed it, and the image shows. There must be something different between your code and mine that makes mine not work.
Then look for the differences. Most of all, check the return value of your table model's getValueAt method.Just before returning something print out what you're going to return.
If that works out OK print out the image's real size in the ThumbnailIcon. Make sure that the width and height are not -1 (meaning an invalid image, at least at the time. It could be still loading). Component implements ImageObserver so if you do it in the paintIcon method that would be easiest.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:It could be a memory problem. Do you see any errors on the console?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Then I suggest you follow my previous suggestions - check out what is returned from getValueAt, what size the image has when painting, etc.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Consider Paul's rocket mass heater. |