i 撰写节目,在点燃时,将进行圈子。 The following Code i ve have contributed to this summary.
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.event.*;
import java.awt.geom.*;
public class test extends JFrame implements ActionListener, MouseListener {
Shape circle = new Ellipse2D.Float(10, 10, 10, 10);
public test () {
setSize(250,150);
addMouseListener(this);
}
public static void main(String[] args) {
//TODO code application logic here
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
test frame = new test();
frame.setVisible(true);
}
});
}
public void actionPerformed(ActionEvent ae) {
}
public void drawCircle(int x, int y) {
Graphics g = this.getGraphics();
g.drawOval(x, y, x, y);
g.setColor(Color.BLACK);
g.fillOval(x, y, 2, 2);
}
public void mouseClicked(MouseEvent e) {
drawCircle(e.getX(), e.getY());
repaint();
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
}
守则是400X400格框架,在半秒点点点击露圈时,问题在于,一旦释放 mo,圈就会消失。 为什么?