• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Shape Drawing - jswing not drawing  RSS feed

 
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.
 
Marshal
Posts: 64494
225
  • 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
Marshal
Posts: 64494
225
  • 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
Marshal
Posts: 64494
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not paintComponents.
And get rid of the paint method.
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!