Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Constructor

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Constructor

    I am trying to create an Applet that draws 3 rectangles that have random size, color, and location. It also needs to draw new rectangles every time it is resized. Also, I need to create a class that represents a rectangle that knows its size, color, location, and how to draw itself.

    I am not really sure how to start the constructor or the Applet.

    I think the constructor looks something like:
    public Rectangle(int x, int y, int size, Color c)

    and it also has a method that looks something like:
    public void draw(Graphics g)

    Any help would be greatly appreciated.

    Brody


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Java Constructor

    Applets don't use a constructor. The startup code is in the init() and start() methods.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Copy Constructor
    By Rhyssa6 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 7th, 2021, 09:12 PM
  2. creating constructor
    By msinc210 in forum Object Oriented Programming
    Replies: 4
    Last Post: May 31st, 2012, 12:15 AM
  3. Constructor
    By kbbaloch in forum Object Oriented Programming
    Replies: 6
    Last Post: February 1st, 2012, 11:40 PM
  4. Constructor help
    By sambar89 in forum Object Oriented Programming
    Replies: 3
    Last Post: November 26th, 2011, 11:17 PM
  5. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM