05-10-2012 11:41 AM
Hi Guys,
Pretty quick one here,
I am looking to draw a circle on the main screen of a phone app i am creating.
So far on the main screen I have drawn 9 rectangles. But on a keypress event I want
to paint on top of these rectangles my circle.
I've used java before to do this op using repaint but am not sure how to
repaint/refresh so i can draw on top of an already drawn shape which happens onload.
Darren
Solved! Go to Solution.
05-11-2012 03:17 AM
05-11-2012 05:53 AM
how would I redraw, repaint doesnt seem to call the paint method again and dopaint doesnt either when I call it.
public MyScreen()
{
super( MainScreen.VERTICAL_SCROLL | MainScreen.VERTICAL_SCROLLBAR );
setTitle("MyTitle");
}
public boolean keyChar(char key, int status, int time) {
if(key == 'e')
{
// Here I want to draw a new circle
}
else
{
}
return true;
}
protected void paint(Graphics g)
{
g1 = (Graphics) g;
super.paint(g1);
drawBoard(g1);
}
public void drawBoard(Graphics g)
{
int y = 0;
int z =0;
for (int i =0; i<= rectangles.length; i++)
{
if(i >= 0 && i <=2)
{
g.drawRect(160+ i * 90 , 100, 90, 90);
}
else if(i >= 3 && i <=5)
{
g.drawRect(160+ y * 90, 190, 90, 90);
y++;
}
else if(i >= 6 && i <=8)
{
g.drawRect(160 + z *90 , 280, 90, 90);
z++;
}
}
}
The above code draws a set of rectangles on the main screen but drawing on top of this how is this done, normally i would just use a repaint on a boolean setting but this does not work
05-11-2012 06:00 AM
05-11-2012 06:04 AM
Thanks, works a charm