Results 1 to 4 of 4
  1. #1
    Jeremy8 is offline Member
    Join Date
    Feb 2009
    Posts
    12
    Rep Power
    0

    Default Drawing a picture (applet) using methods

    Hi, for my class I need to draw a picture in an applet, but it's not as simple as that. The teacher wants different parts of the pictures to have their own methods. I'm having a little difficulty starting out with the basics.

    Can anyone give me an idea on how to do this?

    I started making a separate class with all the methods. Then, in the applet, I tried to have it make a new object of each of those things... didn't work... or is that how I am supposed to do it and maybe I messed something up? I don't know, but please give me advice. :)

  2. #2
    Jeremy8 is offline Member
    Join Date
    Feb 2009
    Posts
    12
    Rep Power
    0

    Default

    OK, this is what I have... idk!

    Java Code:
    *removed by me*
    Last edited by Jeremy8; 04-22-2009 at 07:59 PM.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,199
    Rep Power
    19

    Default

    Check out these tutorials:
    Trail: 2D Graphics (The Java™ Tutorials)
    Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI with JFC/Swing)

    And for a JApplet or any Swing component, override paintComponent, not paint.

    db

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Darryl's right, but let me make one small clarification:

    For a JApplet, JFrame, or other Swing app, do your graphics within a JPanel or JComponent and override this object's paintComponent method. You can then place this JPanel or JComponent into the JApplet's contentPane. The excellent tutorial links in Darryl's post should explain all.

Similar Threads

  1. how to import a picture into an applet
    By cecily in forum Java Applets
    Replies: 2
    Last Post: 01-15-2010, 08:51 PM
  2. Drawing Applet
    By Urgle in forum New To Java
    Replies: 6
    Last Post: 11-19-2008, 08:38 AM
  3. Shape drawing applet not working...
    By evapisces in forum Java Applets
    Replies: 0
    Last Post: 11-17-2008, 11:46 PM
  4. using applet with user-craeted methods
    By munchflo in forum JCreator
    Replies: 0
    Last Post: 11-16-2008, 06:12 AM
  5. Picture help
    By deathnote11 in forum AWT / Swing
    Replies: 13
    Last Post: 06-03-2008, 05:46 PM

Posting Permissions

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