用Graphics的drawLine画线或圆,怎么设置线宽? 用Graphics的drawLine画线或圆,怎么设置线宽?默认的总是1个象素,怎么修改或设置线宽属性?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //Graphics不行,Graphics2D可以,利用setStroke()方法设置Graphics g;g=cv.getGraphics(); Graphics2D g2d = (Graphics2D)g;BasicStroke bs=new BasicStroke(width);//width是线宽,float型g2d.setStroke(bs); g2d.drawRect(10,10,80,80); private void drawNet( Graphics g ){ int height = getHeight(); int width = getWidth(); Graphics2D g2=(Graphics2D)g; coord.setNet(yUnit , xUnit); coord.setNetColor( Color.gray ); g2.setStroke( new BasicStroke(1)); //这局话 coord.drawNet(g); } 求助:JAVA 打印矩阵。输入为1,输出如下三维矩阵;输入为2时,输出五维矩阵;输入为3时,输出为七维矩阵。 java的native方法clone()是怎么实现的 深入jdk,同大家探讨一个问题关于jdbc 帮我看哈我的设计正常吗? 如何读写剪贴板clipboard中混合着string和image的内容 JApplet中的jTextArea为什么不能显示,请帮忙 利用url取图的方法问题!!急问!! 关于deprecated的一个问题 棘手问题:这样为什么会错?? Thinking in Java2代码问题 我的Eclipse怎么不支持中文呢? 有点疑惑,帮我看看!
Graphics g;
g=cv.getGraphics(); Graphics2D g2d = (Graphics2D)g;
BasicStroke bs=new BasicStroke(width);//width是线宽,float型g2d.setStroke(bs);
g2d.drawRect(10,10,80,80);
int height = getHeight();
int width = getWidth();
Graphics2D g2=(Graphics2D)g;
coord.setNet(yUnit , xUnit);
coord.setNetColor( Color.gray );
g2.setStroke( new BasicStroke(1)); //这局话
coord.drawNet(g);
}