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 4 of 4

Thread: inheritance help

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default inheritance help

    i'm currently working on a project where i'm required to create 3 different generators, all of different sizes and color. what i'm trying to do is when i click on one of these rectangles, a new draggable rectangle appears in the upper left corner of the screen. that is how far i've gotten. my problem lies in that the rectangle that appears is a square of default size and color, and doesn't inherit the properties of the rectangle which i click on. i assume this is an interface type problem, however having little practice with the topic, i wouldn't know where to begin. if i'm off track and it's a whole different problem, additional information would be greatly appreciated. thanks in advance.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: inheritance help

    Without any code to show what you are talking about, its hard to say anything about your problem.
    Is this a java programming problem? Your description makes it sound like some GUI design program.
    Can you explain what you are doing and what tools you are using?

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: inheritance help

    we use bluej, and the wheels package. the basic gist of what i'm trying to accomplish is:

    when the program is run, 3 rectangles are on the screen, all of different sizes and colors. for example a red square with the dimensions say 50x50, a green rectangle dimensions 100x50, and a blue rectangle 40x80. when one of these rectangles is clicked, a new rectangle, identical in size and color of the rectangle clicked, appears in the top left of the frame. this block is able to be clicked and dragged across the frame.

    as for the problem i have, i am able to make the three rectangles appear, all of which when clicked create a new rectangle that is able to be dragged. however, the rectangle that appears is the same for when i click any of the rectangles, and has nothing in common with any of the clickable rectangles. i believe the problem i'm having is that within the constructor in the draggable rectangle class, there is no way for me to set the size and color of the rectangle based on the values found in the constructor of the rectangle i click.

    if any more information, such as the code i have so far, is needed, let me know.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: inheritance help

    Sorry, I have no idea what your code is doing and can't recommend anything without seeing the code.

Similar Threads

  1. inheritance
    By b109 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 30th, 2010, 09:23 PM
  2. Static fields and inheritance
    By helloworld922 in forum Java Programming Tutorials
    Replies: 1
    Last Post: January 22nd, 2010, 04:02 AM
  3. Problem with OOP - Inheritance
    By connex in forum Object Oriented Programming
    Replies: 1
    Last Post: December 14th, 2009, 11:11 PM