Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualburnt_casadilla

Posted 11 August 2012 - 03:40 PM

So i have to add a paint method to my ball class and then call the ball paint method from the main paint method? im confused lol

when i created a paint method into the ball class and added the for method in there, nothing was drawn to the screen
[source lang="java"]int i;[/source]

[source lang="java"] public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; } public void paint(Graphics g) { for(i = 0; iLESSTHANNUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); } } }[/source]
[source lang="java"] public void paint(Graphics g) { ball[i].paint(g); g.setColor(Color.black); g.fillOval(xpos - radius, ypos - radius, 2 * radius, 2 * radius); }[/source]



oops forgot the for loop in the main paint method. works perfectly now

[source lang="java"] public void paint(Graphics g) { for(i = 0; iLESSTHANNUM_OF_BALLS; i++) { ball[i].paint(g); } g.setColor(Color.black); g.fillOval(xpos - radius, ypos - radius, 2 * radius, 2 * radius); } }[/source]

#8burnt_casadilla

Posted 11 August 2012 - 03:40 PM

So i have to add a paint method to my ball class and then call the ball paint method from the main paint method? im confused lol

when i created a paint method into the ball class and added the for method in there, nothing was drawn to the screen
[source lang="java"]int i;[/source]

[source lang="java"] public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; } public void paint(Graphics g) { for(i = 0; iLESSTHANNUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); } } }[/source]
[source lang="java"] public void paint(Graphics g) { ball[i].paint(g); g.setColor(Color.black); g.fillOval(xpos - radius, ypos - radius, 2 * radius, 2 * radius); }[/source]



oops forgot the for loop in the main paint method. works perfectly now

#7burnt_casadilla

Posted 11 August 2012 - 03:37 PM

So i have to add a paint method to my ball class and then call the ball paint method from the main paint method? im confused lol

when i created a paint method into the ball class and added the for method in there, nothing was drawn to the screen
[source lang="java"]int i;[/source]

[source lang="java"] public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; } public void paint(Graphics g) { for(i = 0; iLESSTHANNUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); } } }[/source]
[source lang="java"] public void paint(Graphics g) { ball[i].paint(g); g.setColor(Color.black); g.fillOval(xpos - radius, ypos - radius, 2 * radius, 2 * radius); }[/source]

this doesnt work

gave me this error

Exception in thread "AWT-EventQueue-1" java.lang.ArrayIndexOutOfBoundsException

when i made the array public, it drew everything for a split second and then gave me a whole bunch of errors and the screen went blank. i think its updating too fast

#6burnt_casadilla

Posted 11 August 2012 - 03:35 PM

So i have to add a paint method to my ball class and then call the ball paint method from the main paint method? im confused lol

when i created a paint method into the ball class and added the for method in there, nothing was drawn to the screen
[source lang="java"]int i;[/source]

[source lang="java"] public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; } public void paint(Graphics g) { for(i = 0; iLESSTHANNUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); } } }[/source]
[source lang="java"] public void paint(Graphics g) { ball[i].paint(g); g.setColor(Color.black); g.fillOval(xpos - radius, ypos - radius, 2 * radius, 2 * radius); }[/source]

this doesnt work

gave me this error

Exception in thread "AWT-EventQueue-1" java.lang.ArrayIndexOutOfBoundsException

#5burnt_casadilla

Posted 11 August 2012 - 03:34 PM

So i have to add a paint method to my ball class and then call the ball paint method from the main paint method? im confused lol

when i created a paint method into the ball class and added the for method in there, nothing was drawn to the screen
[source lang="java"]int i;[/source]

[source lang="java"] public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; } public void paint(Graphics g) { for(i = 0; iLESSTHANNUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); } } }[/source]
[source lang="java"] public void paint(Graphics g) { ball[i].paint(g); g.setColor(Color.black); g.fillOval(xpos - radius, ypos - radius, 2 * radius, 2 * radius); }[/source]

this doesnt work

#4burnt_casadilla

Posted 11 August 2012 - 03:31 PM

So i have to add a paint method to my ball class and then call the ball paint method from the main paint method? im confused lol

when i created a paint method into the ball class and added the for method in there, nothing was drawn to the screen

[source lang="java"] public Ball(int x, int y, int width, int height, Color mycolor) { this.x = x; this.y = y; this.width = width; this.height = height; this.mycolor = mycolor; } public void paint(Graphics g) { for(int i = 0; iLESSTHANNUM_OF_BALLS; i++) { g.setColor(ball[i].mycolor); g.fillOval((int)ball[i].x, (int)ball[i].y, (int)ball[i].width, (int)ball[i].height); } } }[/source]
[source lang="java"] public void paint(Graphics g) { ball.paint(); g.setColor(Color.black); g.fillOval(xpos - radius, ypos - radius, 2 * radius, 2 * radius); }[/source]

this doesnt work

PARTNERS