Java ile paint programı yapıyorum. Paint kısmını hallettim şimdide arkaplandaki beyaz yerine resim koymam lazım fakat koyduğum resmin üzeri çizilmiyor.
beyaz olduğu zamanki kod:
public void paintComponent(Graphics g){
if(image == null){
image = createImage(getSize().width, getSize().height);
graphics2D = (Graphics2D)image.getGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
clear();
}
g.drawImage(image, 0, 0, null);
}resmi böyle koydum fakat üzeri çizilmiyor:
ImageIcon icon = new ImageIcon("c:\\users\\kadir\\desktop\\1.png");
public void paintComponent(Graphics g){
super.paintComponent(g);
final Image img = icon.getImage();
g.drawImage(img, 0, 0, 1920, 1080, null);
}