question for Java programmers

oleander

CAGiversary!
Feedback
5 (100%)
I'm writing a program with a moving shape, and it never draws it all the way before it moves it (that is, it only gets the bottom have drawn), so it looks very choppy as it is moving across the screen. Does anyone know a way to fix this (that I could understand)? I could try to be more specific if that would help.
 
public void paint(Graphics g)
{
windowGraphics = (Graphics2D)this.getGraphics();
windowGraphics.setColor(new Color(0.5F, 1.0F, 0.4F));
windowGraphics.fill(squareOne);
}

this is the action that happens every 10 ms:
public void actionPerformed(ActionEvent e)
{
updatePosition();
squareOne.setRect(xPosition, yPosition, width, length);
repaint();
}
updatePosition just translates the square right or down, depending on the context
 
[quote name='oleander']public void paint(Graphics g)
{
windowGraphics = (Graphics2D)this.getGraphics();
windowGraphics.setColor(new Color(0.5F, 1.0F, 0.4F));
windowGraphics.fill(squareOne);
}

this is the action that happens every 10 ms:
public void actionPerformed(ActionEvent e)
{
updatePosition();
squareOne.setRect(xPosition, yPosition, width, length);
repaint();
}
updatePosition just translates the square right or down, depending on the context[/QUOTE]

OMFG S0urcE c0dE to HL2!!!1!
 
Possibly something with either the speed of the PC or monitor response/refresh rate?

I don't know if you need to to repaint every 10 ms, maybe make it dependent on the monitor refresh rate. I'm not real sure, I usually program in C++ and nothing graphical, just offering suggestions.
 
[quote name='tdphillips']Possibly something with either the speed of the PC or monitor response/refresh rate?

I don't know if you need to to repaint every 10 ms, maybe make it dependent on the monitor refresh rate. I'm not real sure, I usually program in C++ and nothing graphical, just offering suggestions.[/QUOTE]
Thanks, I'll look into that.
 
bread's done
Back
Top