Results 1 to 2 of 2
  1. #1
    wassat676 is offline Member
    Join Date
    May 2011
    Posts
    11
    Rep Power
    0

    Default a "draw()" function

    So i have this assignment, and in it im supposed to make a shape class (circle, sqare, etc.) and then extend that class and add a "draw()" function, some colors, blabla. The endgame is, we take another students shape and combine it into a GUI application. Press buttons, shapes appear. All of this is fine and I understand, but my instructor says the draw() function has to take a Graphics object as an argument, am I crazy or is paintComponent() the exact same thing. How would any of you implement this draw() function. I have do it because we are adding the draw() method to an interface with some other things as part of the next assignment.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    The paintComponent method is called by the JVM. It can do some stuff and then call your new draw methods as needed.

Similar Threads

  1. Replies: 3
    Last Post: 04-29-2011, 01:08 AM
  2. How correctly invoke function "round"?
    By artemff in forum New To Java
    Replies: 2
    Last Post: 01-01-2010, 11:31 AM
  3. How "Pattern.matches(regex, input)" function works?
    By kishan in forum Advanced Java
    Replies: 2
    Last Post: 04-26-2009, 12:46 AM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •