Results 1 to 2 of 2
  1. #1
    blackbirdfly is offline Member
    Join Date
    Nov 2013
    Rep Power

    Default Help with a program that asks a user for points and draws a line from said points

    Hi, so my teacher makes everything 100x more complicated than it should and this lab is making me so frustrated it isn't even funny. I'm sure that there is a easy solution that I am completely missing lol.

    This is what he wants: He wants us to prompt the user to input x values and y values (that will be entered into an array when clicking one of the two buttons (this one will say: Add point)). When they click the second button (draw lines), it should take all the points and draw a line that connects all the points together using a method that we write. In the method we have to call the paint method up which the lines will be drawn. The lines drawn should be touching every point added. It shouldn't have parameters. It will also use Graphics painter = getGraphics(); We can't use frames either.

    I have everything up until the method understood.

    I guess what I really need help is an explanation on how to write a method that will draw a line from points inputted that is called up in the action listener when the second button (draw lines) is pressed.

    Sorry for such a beginner question :P

    Any help will be appreciated, thank you!

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Help with a program that asks a user for points and draws a line from said points

    Graphics has a method that does that.
    Just look at the API.

    So you need to loop over the array of points an draw a line between a point and its predecessor.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 09-19-2013, 04:27 AM
  2. Points in a line
    By mrguy in forum Java Gaming
    Replies: 7
    Last Post: 07-03-2012, 05:29 PM
  3. Replies: 1
    Last Post: 08-11-2011, 11:46 AM
  4. Replies: 2
    Last Post: 08-24-2008, 01:30 AM
  5. Replies: 0
    Last Post: 06-28-2008, 10:25 PM

Tags for this Thread

Posting Permissions

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