How to draw lines in Java

前端 未结 10 2040
梦毁少年i
梦毁少年i 2020-11-30 02:42

I\'m wondering if there\'s a funciton in Java that can draw a line from the coordinates (x1, x2) to (y1, y2)?

What I want is to do something like this:



        
10条回答
  •  借酒劲吻你
    2020-11-30 03:14

    To answer your original question, it's (x1, y1) to (x2, y2).

    For example,

    This is to draw a horizontal line:

    g.drawLine( 10, 30, 90, 30 );
    

    vs

    This is to draw a vertical line:

    g.drawLine( 10, 30, 10, 90 );
    

    I hope it helps.

提交回复
热议问题