JAVA正弦函数的构造我这样写可以么?super.paintComponent(g);还有最重要的函数表达式都不是很明白意思。
classsinsextendsJPanel{protectedvoidpaintComponent(Graphicsg){super.paintComponent(g)...
class sins extends JPanel{
protected void paintComponent(Graphics g){
super.paintComponent(g);
g.drawString("-2\u03c0", 100, 100);
g.drawString("0", 200, 100);
g.drawString("2\u03c0", 300, 100);
g.drawString("x", 365, 115);
g.drawString("y", 215, 25);
Polygon p = new Polygon();
for(int x=-100;x<=100;x++){
p.addPoint(x+200,100-(int)(50*Math.sin((x/100.0)*2*Math.PI)));
}
g.drawPolyline(p.xpoints, p.ypoints,201);
g.drawLine(10, 100, 370, 100);
g.drawLine(200, 20, 200, 150);
g.drawLine(200, 20, 190, 30);
g.drawLine(200, 20, 210, 30);
g.drawLine(370, 100, 360, 90);
g.drawLine(370, 100, 360, 110);
} 展开
protected void paintComponent(Graphics g){
super.paintComponent(g);
g.drawString("-2\u03c0", 100, 100);
g.drawString("0", 200, 100);
g.drawString("2\u03c0", 300, 100);
g.drawString("x", 365, 115);
g.drawString("y", 215, 25);
Polygon p = new Polygon();
for(int x=-100;x<=100;x++){
p.addPoint(x+200,100-(int)(50*Math.sin((x/100.0)*2*Math.PI)));
}
g.drawPolyline(p.xpoints, p.ypoints,201);
g.drawLine(10, 100, 370, 100);
g.drawLine(200, 20, 200, 150);
g.drawLine(200, 20, 190, 30);
g.drawLine(200, 20, 210, 30);
g.drawLine(370, 100, 360, 90);
g.drawLine(370, 100, 360, 110);
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
2014-12-02
展开全部
这个是画图的类。。。。。。java中,要绘图,就使用paint/paintComponent 事件。。。。。。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询