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:
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.