Click to See Complete Forum and Search --> : fillOval/button problem


acumen101
11-13-2005, 02:58 PM
ok, I had a problem like this, but now things are different. The situation is that I am developing a game where I'm using buttons as characters; 8 buttons per team. The movement of each character is unlimited in direction, but limited by a range. The range of movement of each character is displayed to the user when the button is selected. The problem is that when said button is selected, the circle that displays the movement radius does not show and when the button is moved, the place where the button should be is not showing the button at all; like it was not even drawn. I know I'm using the right code to draw the circle, but any light that anyone can shed on this situation would be most appreciated.

Khalid Ali
11-13-2005, 05:31 PM
don't have your code to look at, however, my guess is that its a logic problem, meaning that you need to reset your settings that when button needs to be painted on top of circle, it does. As you mention it, it points to the fact that the circle painting takes over the button and hides it

Waylander
11-13-2005, 08:23 PM
Without looking at your code and at a guess..

Im thinking that if your components arent being drawn you need to call the setVisible(true); or validate(); method depending on your layout (validate for gridbag visible for rest) last on whatever container your components are in.

Waylander.

acumen101
11-14-2005, 12:33 PM
ok, here's the code I'm using. The first part is from a method that checks to see what action is performed; what buttons are selected. The second part is the code I'm using to draw the circles, which show the user the radius of movement (in green) and attack (in yellow)

if (event.getSource() == red08)
{
System.out.println("Red 08");
if (red08Obj.life > 0) // 1 - Checks to see if character is"tagged out"
{
red08Obj.isActive = false; // 2 - Keeps button from being used
red08Obj.life --; // 3 - One turn closer to being used
}
else
s = red08Obj.Red08().getX();
t = red08Obj.Red08().getY();
PaintRadi(s,t);
red08Obj.isActive = true;
}

public void PaintRadi(int x, int y)
{
temp_g.setColor( Color.green );
temp_g.fillOval( 25 + x, 40 + y, 200, 200 );
temp_g.setColor( Color.yellow );
temp_g.fillOval( 75 + x, 90 + y, 100, 100 );
}

NOTE: "temp_g" is declared as "Graphics temp_g = getGraphics();" right after the first set of brackets of the program.

acumen101
11-19-2005, 02:21 PM
can anyone help me figure out how to use validate in this code?

Oak
11-20-2005, 10:20 AM
Ill help if you give me the fully compilable code.