• Post Reply Bookmark Topic Watch Topic
  • New Topic

Shape Drawing - jswing not drawing  RSS feed

 
mel tlete
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I'm creating a drawing applet using jswing and awt. as a newbie to jswing I really don't understand all jswing functions, so i follow books and other
helpful forums. now I'm stuck and basically in desperate need of help and good direction. I don't know other errors, aside from not executing the drawing part. so I really
don't understand how to call repaint using an event button. please see code below.




when I try calling the paint method declaring values. I get a drawing result, so I know that my paint is being called. but I cannot figure out why my Drawing Button doesn't return any result.
this is 5 days problem of mine please help.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use the paint method. Override paintComponent (protected access). Not paintComponents.

And welcome to the Ranch
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can a button return a result? Only methods return results and the method you are using has void return type.
 
mel tlete
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the suggestion. but I'm not sure I understand Override paintComponent (protected access), can you explain more and I will check the link.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not paintComponents.
And get rid of the paint method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!