• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to paint a java.awt.Image in a JScollPane?

 
John Wells
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
I'm trying to paint an image inside a JScrollPane. My app is essentially structured as:
JFrame
|
JDesktopPane
|
JInternalFrame
|
JScrollPane
|
JPanel
|
java.awt.Image
But when I try to paint the image in the JPanel's paint method, it doesn't seem to open a viewport around the whole image. The image is there, and the scroll bars are there (I force them to always be displayed), but the image is cropped and the scrollbars do not scroll across the entire image. In other words, it seems like the image is being painted, but the viewport is too small.
Can anyone offer any suggestions or pointers to good tutorials? I'm very new to working with images in Java.
Thanks very much for your help.
 
Sharon Zakhour
Author
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have an example in the tutorial that paints an image in a scroll pane.
In our example, the ScrollablePicture class is a subclass of label. You
can see it here:
http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html
Sharon Zakhour
 
John Wells
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, ok...I saw that tutorial, but because it uses an ImageIcon, I assumed that this wasn't a valid class to use for regular images (i.e., not "icons").
So is this not the case? Is ImageIcon the defacto image class in Swing, for all sizes?
Thanks for your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic