Can you post what you have so far, preferably in SSCCE form (like what I posted: short, runnable, demonstrates the point)?
But basically, the paintComponent method has to be in a class that...
Type: Posts; User: KevinWorkman
Can you post what you have so far, preferably in SSCCE form (like what I posted: short, runnable, demonstrates the point)?
But basically, the paintComponent method has to be in a class that...
For a simple game, simply drawing whatever you need in the paintComponent method should work fine. And if you do experience any issues, it wouldn't be hard to go from "my" method to the method of...
And for what it's worth, this is what's causing your flickering:
You get the graphics and draw to it.
You then tell the component to repaint.
Since you don't have any code in paintComponent,...
I wouldn't try the "complicated" approach until you actually need it. You might be better off just painting the necessary regions by calling repaint with only the changed clip: Component (Java...
I'm sorry, but despite what everybody else is saying, if you're calling getGraphics() on a GUI component to do painting, you're doing it wrong. That's what's causing your flickering.
Some overly...
Tell your friend to show you some benchmarks (compared to benchmarks in other languages) proving that Java is "super slow". Until then, he's talking nonsense.
I can't speak for your teacher or tutor. I'm not sure what you actually asked them, so I'm not sure what they were saying was complicated. But this might be worth checking out: Painting in AWT and...
I agree with the first part of your post, but I'm not convinced this is the case. The OP is doing the wonky (incorrect) getGraphics() approach to painting. That's bad. I would think the OP should fix...
Which is false.
I can't really comment because I have no idea what the assignment was, or what the other students were actually doing. It doesn't make a ton of sense to me that you would be...
Fair enough. But we aren't talking about assembly. That's the beauty of Java: it's a high level language. If you write the code correctly, it will handle much of the optimization itself. So if you're...
Code optimization is important in a few cases, but premature optimization, especially with beginners, leads to all kinds of painful "shortcuts" that actually hurt the understandability,...
And since I mentioned incorrect threading practices, I guess I should point this out: What Thread are you putting to sleep here? If it's the EDT, you're going to have a big problem with response time...
Sorry, but that's wrong. The problem is incorrect GUI code. In fact, much of Java's "reputation" for being slow has been caused by people not fully understanding GUI coding, especially with regard to...
That's not how you do painting. You almost never want to use the getGraphics() function like that. Just call repaint, and do the custom painting in an overriden paintComponent() method.