I just managed to put some scrollbars on the jScrollPane1 but I still can't get it to show the image.
Here's the new 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);
Scrollbar columnView = new Scrollbar(Scrollbar.HORIZONTAL);
Scrollbar rowView = new Scrollbar(Scrollbar.VERTICAL);
jScrollPane1.setColumnHeaderView(columnView);
jScrollPane1.setRowHeaderView(rowView);
jScrollPane1.setBackground(Color.BLACK);
g2D.drawImage(image, (jScrollPane1.getWidth() - image.getWidth())/2, (jScrollPane1.getHeight() - image.getHeight())/2, this);
g2D.setPaint(Color.BLACK);
jScrollPane1.setOpaque(true);
jScrollPane1.paintComponents(g2D);
}
catch ( Exception e ) {
}
finally {
}