画直线 drawLine(int x1,  int y1,   int x2,  int y2)Parameters:
x1 - the first point's x coordinate.
y1 - the first point's y coordinate.
x2 - the second point's x coordinate.
y2 - the second point's y coordinate画空心圆   drawOval(int x, int y, int width, int height)
实心圆    fillOval(int x,  int y, int width, int height)Parameters:
x - the x coordinate of the upper left corner of the oval to be filled.
y - the y coordinate of the upper left corner of the oval to be filled.
width - the width of the oval to be filled.
height - the height of the oval to be filled.

解决方案 »

  1.   

    多谢congcat(网破鱼欢) 
    还有个问题问大家,本来我的窗口有一些输入框,按钮之类的东西,用
     drawLine(int x1,  int y1,   int x2,  int y2) 画一条直线后,就都被覆盖了(就像放上了一张画有一条直线的灰色的纸)然后随便点到哪个控件,哪个上面的“纸”就破了看到下面的控件
    我想画的线是在运行某些东西后填上去的,有什么办法让我只填加一条线,而不要那个灰色的背景?还有,JAVA 里可不可以指定像 PANEL 那样的控件,在里面画图,并且坐标的值也是根据在 PANEL 的对位置来算而不是相对原来那个窗口
      

  2.   

    覆盖的话,要在paintComponent方法一开始调用super.paintComponent确保绘制顺序