Why can't I access my panel's getWidth() and getHeight() functions?
I'm writing a simple program to test out basic GUI. The program prints a letter in the middle of the screen and allows the user to move it with the arrow keys. Everything works fine, but when I try to center the letter at the start of the program, it seems that the getWidth and getHeight functions aren't returning the proper numbers. Here's the snippet containing my Panel class static class LinePanel extends JPanel{ int xCenter = getWidth() /2; int yCenter = getHeight() /2; private int x = xCenter; private int y = yCenter; private char keyChar = 'A'; public LinePanel(){ addKeyListener(new