支持double类型是没有意义的,因为组件的绘制区域是有N*M个像素绘制成,精确到double没有意义。
你需要把你的坐标点 转化成像素坐标。你告诉我你的 double x,double y 是什么意思。给你写几句代码,Component c=new JLabel();Graphic g=c.getGraphic();c.setPreferredSize(new Dimension(200,200));// c组件的大小为200*200像素Point start=new Point(0.3,0.2);//Point end=new Point(0.1,0.1);//如果要画出这条线,应该如下g.drawLine(Math.round(0.3*200),Math.round(0.2*200),Math.round(0.1*200),Math.round(0.1*200)); |