求大神看看我的java程序哪里错了
importjavax.swing.*;importjava.awt.*;publicclassSimpleAnimation{intx=70;inty=70;publi...
import javax.swing.*;
import java.awt.*;
public class SimpleAnimation{
int x=70;
int y=70;
public static void main (String[] args){
SimpleAnimation gui=new SimpleAnimation ();
gui.go();
}
public void go () {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MyDrawPanel drawPanel = new MyDrawPanel();
frame.getContentPane().add(drawPanel);
frame.setSize(300,300);
frame.setVisible(true);
for (int i=0;i<130;i++){
x++;
y++;
drawPanel.repaint();
try{
Thread.sleep(50);
} catch(Exception ex) { }
}
}
class MyDrawPanel extends Jpanel{
public void paintComponent(Graphics g) {
g.setColor(Color.green);
g.fillOval(x,y,40,40);
}
}
} 展开
import java.awt.*;
public class SimpleAnimation{
int x=70;
int y=70;
public static void main (String[] args){
SimpleAnimation gui=new SimpleAnimation ();
gui.go();
}
public void go () {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MyDrawPanel drawPanel = new MyDrawPanel();
frame.getContentPane().add(drawPanel);
frame.setSize(300,300);
frame.setVisible(true);
for (int i=0;i<130;i++){
x++;
y++;
drawPanel.repaint();
try{
Thread.sleep(50);
} catch(Exception ex) { }
}
}
class MyDrawPanel extends Jpanel{
public void paintComponent(Graphics g) {
g.setColor(Color.green);
g.fillOval(x,y,40,40);
}
}
} 展开
展开全部
package com.zju.lld;
import javax.swing.*;
import java.awt.*;
public class SimpleAnimation{
int x=70;
int y=70;
public static void main (String[] args){
SimpleAnimation gui=new SimpleAnimation ();
gui.go();
}
public void go () {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MyDrawPanel drawPanel = new MyDrawPanel();
frame.getContentPane().add(drawPanel);
frame.setSize(300,300);
frame.setVisible(true);
for (int i=0;i<130;i++){
x++;
y++;
drawPanel.repaint();
try{
Thread.sleep(50);
} catch(Exception ex) { }
}
}
class MyDrawPanel extends JPanel{
public void paintComponent(Graphics g) {
g.setColor(Color.green);
g.fillOval(x,y,40,40);
}
}
}
拿去运行吧
import javax.swing.*;
import java.awt.*;
public class SimpleAnimation{
int x=70;
int y=70;
public static void main (String[] args){
SimpleAnimation gui=new SimpleAnimation ();
gui.go();
}
public void go () {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MyDrawPanel drawPanel = new MyDrawPanel();
frame.getContentPane().add(drawPanel);
frame.setSize(300,300);
frame.setVisible(true);
for (int i=0;i<130;i++){
x++;
y++;
drawPanel.repaint();
try{
Thread.sleep(50);
} catch(Exception ex) { }
}
}
class MyDrawPanel extends JPanel{
public void paintComponent(Graphics g) {
g.setColor(Color.green);
g.fillOval(x,y,40,40);
}
}
}
拿去运行吧
追问
谢谢
展开全部
class MyDrawPanel extends Jpanel 中Jpanel类名写错了。应该改为JPanel,P要大写。
追问
谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
JPanel
class MyDrawPanel extends Jpanel 中没有Jpanel这个类。 要继承 JPanel
其他没有问题。
请采纳。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询