while trying to create a panel for my game, I am trying to use a number of things such as setPreferredSize, setBackground, and more, but for some reason all of these are being underlined. Also, I’m following this video: https://www.youtube.com/watch?v=om59cwR7psI&t=702s and I have been following the steps very closely so I’m not sure why it isn’t working for me.
package main;
import java.awt.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.Dimension;
public class GamePanel {
final int originalTileSize = 16; //16 x 16 tiles
final int scale = 3;
final int tileSize = originalTileSize * scale;
final int maxScreenColumn = 16;
final int maxScreenRow = 12;
final int screenWidth = tileSize * maxScreenColumn; //768 pixels
final int screenHeight = tileSize * maxScreenRow; //576 pixels
public GamePanel() {
this.setPreferredSize(new Dimension(screenWidth, screenHeight));
this.setBackground(Color.black);
this.setDoubleBuffered(true);
}
}
New contributor
John Sanchez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.