View Single Post
  #3 (permalink)  
Old 03-24-2008, 12:10 AM
Birkoff Birkoff is offline
Member
 
Join Date: Mar 2008
Posts: 3
Birkoff is on a distinguished road
Thanks for the reply.
It took me some time to read all the stuff you posted but I am finally getting somewhere.

I am having a problem using JScrollPane and would like to know if anyone around can help me with it.

Here's how I am drawing the image:
Code:
private void jButton1MouseReleased(java.awt.event.MouseEvent evt) { String path = "/home/birkoff/wallpapers/rei_forever.jpg"; Graphics g = jScrollPane1.getGraphics(); Graphics2D g2D = (Graphics2D) g; try { BufferedImage image = ImageIO.read(new File(path)); ImageIcon icon = new ImageIcon(image); g2D.drawImage(image, (jScrollPane1.getWidth() - image.getWidth())/2, (jScrollPane1.getHeight() - image.getHeight())/2, this); jScrollPane1.paintComponents(g2D); } catch ( Exception e ) { } finally { }
I don't know why but this only draw the border of the image (if I set the jScrollPane1's border to no-boarder then no image is draw at all).

So can anyone please point me to my error ?

Also, if anyone knows how to resize the image so it fits window (or if you know how to enable the scrolls on JScrollPane) please gimme a hand.

There were some code for this on one of the links the previous user posted but I couldn't understand them.

Thanks in advance.
Reply With Quote