Search:

Type: Posts; User: KevinWorkman

Search: Search took 0.09 seconds.

  1. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  2. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  3. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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,...
  4. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  5. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  6. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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.
  7. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  8. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  9. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  10. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  11. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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,...
  12. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  13. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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...
  14. Replies
    41
    Views
    8,481

    Re: 60FPS refresh loop

    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.
Results 1 to 14 of 14