• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic