I've written a simulation in Java, and, with help, got a class that extends JPanel. A summary of the implementation is as follows:
public class Map extends JPanel {
BufferedImage truck1;
public Map() throws IOException {
truck1 = ImageIO.read(getClass().getResource("Truck.png"));
}
protected void paintcomponent (Graphics g) {
super.paintComponent(g);
g.drawImage(truck1, 50, 100, 300, 300, this);
}
How do I go about initializing or calling this object in my main function, to make it draw the objects on screen?
How about using google: Swing tutorial
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.