Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By kelogg

Thread: Super new

  1. #1
    kelogg is offline Member
    Join Date
    Oct 2014
    Rep Power

    Default Super new

    With no response from my professor, I'm in search of some help.

    My goal is to make 2 rectangles in the same window. so far I have this.

    import javax.swing.JComponent;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;

    public class BoxComponent extends JComponent
    public void paintComponent(Graphics g)
    Graphics2D g2 = (Graphics2D) g;

    Rectangle box = new Rectangle(10, 10, 250, 50);

    Rectangle box2 = new Rectangle(20, 20, 250, 50);


    After running the program I get one rectangle, the red one. If I take the code out for the red rectangle, I only get 1 blue one. What am I missing?

  2. #2
    kelogg is offline Member
    Join Date
    Oct 2014
    Rep Power

    Default Re: Super new

    Figured it out. Simple mistake. Had both boxes labeled as box.
    Tolls likes this.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Super new

    Thank you for letting us know that your problem is solved. To be more specific, you were filling the same Rectangle twice and not making use of the Rectangle box2.

    For your future reference: BB Code List - Java Programming Forum - Learn Java Programming

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. super fun dog
    By uc200511 in forum Entertainment
    Replies: 1
    Last Post: 07-28-2012, 11:56 PM
  2. I am a super noob with a super noob question.
    By LittleZoppo in forum Java Applets
    Replies: 3
    Last Post: 04-27-2012, 03:50 AM
  3. calling variable using super super..
    By Stephen Douglas in forum New To Java
    Replies: 7
    Last Post: 08-16-2010, 06:12 AM
  4. this() and super() ?
    By bob in forum New To Java
    Replies: 4
    Last Post: 08-13-2009, 04:56 PM
  5. super
    By dj kourampies in forum New To Java
    Replies: 5
    Last Post: 01-23-2009, 03:07 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