import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.imageio.*;
import java.io.*;
public class Pole extends JPanel {
private Image santa;
private Image fon;
public int x = 350;
//Здесь создается конструктор класса Pole
public Pole() {
try {
santa = ImageIO.read(new File("C:\\gifts\\santa.png"));
fon = ImageIO.read(new File("C:\\gifts\\bg.jpg"));
}
catch (IOException ex) {
System.out.println("Изображение не найдено");
}
Timer timerDraw = new Timer(16, new ActionListener() {
public void actionPerformed(ActionEvent a) {
repaint();
}
});
timerDraw.start();
}
public void paintComponent(Graphics gr) {
super.paintComponent(gr);
gr.drawImage(fon, 0, 0, null);
gr.drawImage(santa, x, 465,100,100, null);
}
}