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.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: drawing just a line, please

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Thanked 0 Times in 0 Posts

    Default drawing just a line, please

    i need a function which will receive x1, y1, x2, y2 for two points and draw a line. JFrame and Jpanel are already in place. this passing graphics g as parameter appears insurmountable. all examples of drawline invariably demonstrate a line for a fixed coordinates. not variable.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: drawing just a line, please

    See tutorials on custom painting here: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    And here: Custom Painting - Tutorials - Static Void Games
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    ydandurkar (April 17th, 2014)

Similar Threads

  1. Drawing a line and repaint()
    By rogerbacon in forum AWT / Java Swing
    Replies: 3
    Last Post: October 19th, 2011, 07:08 PM
  2. Replies: 10
    Last Post: September 16th, 2011, 07:49 PM
  3. Java Frame Buffer Line drawing
    By tcmei in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 17th, 2011, 06:55 AM
  4. Line Drawing Program
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 13th, 2010, 03:54 PM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM