I think I found a workaround, might be messy code, but worth a test.
Type: Posts; User: Melawe
I think I found a workaround, might be messy code, but worth a test.
The problem with the paintComponent() is I can't use it in an if-else statement. The if-else statment checks what key was pressed, and ignores it if it is a certain key.
I want to get the graphics object associated with the canvas object, then call its drawString() method. So if its named graph, I can call graph.drawString().
I was trying to get the Graphics object associated with a Canvas object, then use it's drawString method. I'm making a program that handles key events and then draws them on a Canvas object. One...
I used this code:
System.out.println(comp.getGraphics());
Result:
...