Java如何使用GUI绘制线条
1个回答
2018-06-13 · 百度知道合伙人官方认证企业
关注
展开全部
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphcis2D g2d = (Graphics2D)g;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setStroke(new BasicStroke(2f));
g.setPaint(Color.BLUE);
g.drawLine(x1,y1,x2,y2);
g.draw(new Line2D.Double(x1d,y1d,x2d,y2d));
}
在JPanel子类的paintComponent方法里绘制。
super.paintComponent(g);
Graphcis2D g2d = (Graphics2D)g;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setStroke(new BasicStroke(2f));
g.setPaint(Color.BLUE);
g.drawLine(x1,y1,x2,y2);
g.draw(new Line2D.Double(x1d,y1d,x2d,y2d));
}
在JPanel子类的paintComponent方法里绘制。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询