java语言中用Eclipse话圆,为什么图形不显示出来?
packageedu.pku.tds;importjava.awt.*;importjavax.swing.*;publicclassph7423extendsJFram...
package edu.pku.tds;
import java.awt.*;
import javax.swing.*;
public class ph7423 extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
public static void main(String[] argv){
JFrame frame=new ph7423();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600,600);
frame.setVisible(true);
}
public void pain(Graphics g){
g.drawString("circle 99", 20, 20);
int x0=getSize().width/2;
int y0=getSize().height/2;
for(int r=0;r<getSize().height/2;r+=10){
g.drawOval(x0-r, y0-r, r*2, r*2);
}
}
Color getRandomColor(){
return new Color(
(int) (Math.random()*256),
(int) (Math.random()*256),
(int) (Math.random()*256)
);
}
}
请大侠明示哪里有问题?小弟谢过了!!! 展开
import java.awt.*;
import javax.swing.*;
public class ph7423 extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
public static void main(String[] argv){
JFrame frame=new ph7423();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600,600);
frame.setVisible(true);
}
public void pain(Graphics g){
g.drawString("circle 99", 20, 20);
int x0=getSize().width/2;
int y0=getSize().height/2;
for(int r=0;r<getSize().height/2;r+=10){
g.drawOval(x0-r, y0-r, r*2, r*2);
}
}
Color getRandomColor(){
return new Color(
(int) (Math.random()*256),
(int) (Math.random()*256),
(int) (Math.random()*256)
);
}
}
请大侠明示哪里有问题?小弟谢过了!!! 展开
1个回答
推荐于2016-05-19
展开全部
public void paint(Graphics g){ /////////////这打错单词了
super.paint();/////////////////////添加一行
g.drawString("circle 99", 20, 20);
super.paint();/////////////////////添加一行
g.drawString("circle 99", 20, 20);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询