• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help on Graphics and repaint

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I don`t know if this is the right place to post my topic but I really need help from you.
I have two questions that I can`t find any answers to them.

In java.awt package there is an graphics class this class is abstract class and within it a lot of abstract methods for example lets take drawOval method all I want to know:
1- when I override paint method of an component like this:
public void paint(Graphics g) { /*some code*/ }
If I write g.drawOval and give the method it`s parameter it`s really draw an oval how this happened when this method is abstract and it has no code within it ??? Is there are some default code in abstract methods or what??? And if this is true whrer to write this code ???
2- when I want to call paint method I have read that I should use repaint(). why? and how repaint call paint if I checked repaint source code & it does not call paint method??? and why I can`t just call paint method ???


I really don`t know if these questions are stupid but if they are or not please answer me cause I can`t do any thing except searching answers .....
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

osama felfel wrote:... I really need help from u.


Please use real words when posting to the forums. Abbreviations such as "u" in place of "you" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
osama felfel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I`m really sorry and I will edit my post
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And people will be more likely to help if they know what the thread is about.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While the paint method says that it receives a Graphics object as a parameter, this method really doesn't receive a simple Graphics object. Instead it must receive an object of a class that is derived from Graphics, one that implements all the abstract methods. It is not necessary to know how the JVM implements the methods, it is not necessary to know the name of this class (and indeed, the class may have no name -- an anonymous class). All that you need to know is that the object is of a class that is descendant from the Graphics class and that obeys all the rules stipulated by the Graphics class method definitions.
 
We can walk to school together. And we can both read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic