Results 1 to 2 of 2
  1. #1
    Manojx is offline Member
    Join Date
    Mar 2011
    Rep Power

    Exclamation how to provide X & Y values for creating polygon? plz refer below

    hi to all

    Here i have been trying to do a paint application something like there are
    2 buttons such as RECTANGLE , ELLIPSE by following those buttons you have some
    EMPTY SPACE which enables you to draw these shapes mentioned Above

    based on your need you can select a shape either one of these before you draw
    so that selected image will be drawn in the EMPTY SPACE but the image appears only after your mouse pointer drawn on the empty space, but not image appeared automatically when the button is selected

    So to implement this RECTANGLE ,ELLIPSE i just want these two methods



    for EXAMPLE Consider about RECTANGLE in this methods to find height & width of RECTANGLE i just create 2 variable and by subtracting end point of cursor with the Starting point found height and width of rectangle
    this is inside a public void paint method

    int width = end.x - start.x; // declaring variables
    int height = end.y - start.y; // declaring variables

    g.drawRect(start.x, start.y, width, height); // declaring variables to draw RECTANGLE

    but now i want to implement POLYGON and the method of this something like
    this X & Y points with the N Points

    int xpoints[] = {25, 145, 25, 145, 25};
    int ypoints[] = {25, 25, 145, 145, 25};
    int npoints = 5;

    g.drawPolygon(xpoints, ypoints, npoints);

    so in this case i exactly don't know How to provide X & Y values based on where the polygon drawn in empty space

    and i'm not allowed to draw polygon just by providing X & Y Values(NUMBERS)

    Instead of that i need something like getting X & Y values from a EMPTY SPACE and apply those X & Y values instead of numbers

    DO I need to use something like X1.y1.x2,y2,x3,y3........x5,y5

    i tried for this but not working any help would be much appreciated

    Thanks in advance

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power

Similar Threads

  1. Replies: 3
    Last Post: 03-15-2011, 07:49 PM
  2. Refer to an object from an array/for loop
    By Chro in forum New To Java
    Replies: 2
    Last Post: 11-09-2010, 07:12 PM
  3. Please provide some help
    By saurabh_87 in forum New To Java
    Replies: 3
    Last Post: 04-23-2009, 09:38 AM
  4. [SOLVED] Creating List of Values Using ClipBoard Object
    By Judoon_Platoon in forum Java Applets
    Replies: 2
    Last Post: 05-21-2008, 09:07 AM
  5. Refer a good Java compiler
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 08:31 AM

Posting Permissions

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