Results 1 to 7 of 7
  1. #1
    cassysumandak is offline Member
    Join Date
    Mar 2009
    Posts
    38
    Rep Power
    0

    Default How to copy a polygon

    How can I copy a polygon. This code doesn't work :-(

    Java Code:
    if(e.getSource() == Copy){		
    	Polygon copyPolygon = new  Polygon(select.xpoints,selected.ypoints,selected.npoints);
    	copyPolygon.translate(10,10);
    	triangles.add(copyPolygon);
    	repaint();
    }

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

    Default

    when you say it doesn't work, what happens? Does it not compile? Does it throw an exception during execution?

    Also, is it important that two out of 3 of your parameters use the selected object (selected.ypoints and selected.npoints) while the first parameter uses select (select.xpoints)?

  3. #3
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    What does "doesn't work" mean?

    Java Code:
    Polygon copyPolygon = new  Polygon(select.xpoints,selected.ypoints,selected.npoints);

    This line does, in fact, create a new polygon with the same points and in the same order as selected. Or it would if you corrected the typo: select in the first argument should be selected.

  4. #4
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    You would think the OP would know how to ask a question given that he always cross posts the questions in other forums as well. This is about the third question that I can remember that has been posted here and at stackoverflow.com.

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

    Default

    OP, you are being very rude here by cross-posting without notification or providing links. Please respond to this issue. You will risk being on many ignore lists (including mine) until you change this behavior.

  6. #6
    cassysumandak is offline Member
    Join Date
    Mar 2009
    Posts
    38
    Rep Power
    0

    Default

    Thanks, it is my mistake. I don't realized the typo :-)

  7. #7
    cassysumandak is offline Member
    Join Date
    Mar 2009
    Posts
    38
    Rep Power
    0

    Default

    I am sorry, it wont happen again. I don't know that posting to many forums is not allowed, but I have no bad intention doing it. It just that, sometimes I need a response so quickly and with hope that I will get more feedback and I can solve the problem. I am so sorry that this caused inconvenience.

Similar Threads

  1. Drag polygon
    By cassysumandak in forum New To Java
    Replies: 5
    Last Post: 03-10-2011, 06:30 PM
  2. Color Brown and Polygon help
    By Keno777 in forum Java 2D
    Replies: 2
    Last Post: 10-04-2009, 10:51 AM
  3. colllision rectangle-polygon
    By marina in forum New To Java
    Replies: 4
    Last Post: 01-28-2009, 09:14 AM
  4. polygon-shaped JComponent
    By zenMarko in forum New To Java
    Replies: 2
    Last Post: 11-04-2008, 06:06 PM
  5. How to Fill a Polygon in Java
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-22-2008, 11:10 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
  •