I'm having small issue with drawing on panel. Neither image or text appears, however background is set correctly therefore it has to be due some issue inside my paintComponent() method.
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO ;
import javax.swing.JPanel;
public class RottrThumbnailsPanel extends JPanel{
RottrThumbnailsPanel(){
init();
setBackground(Color.BLUE);
setSize(new Dimension(400,400));
this.setVisible(true);
}
private void init(){
repaint();
}
public void painComponent(Graphics g){
super.paintComponent(g);
BufferedImage img = null;
try{
img = ImageIO.read(new File("/pdfrotator/res/img/open_green.png"));
}
catch(IOException ioe){
ioe.printStackTrace();
}
g.drawImage(img, 100, 100, 50, 50, Color.WHITE, this);
g.setColor(Color.BLACK);
g.drawString("Hello Peter", 0,200);
}
}