progJ.pdf progJ-s.pdf progJ-e.pdf 記事一覧 |
![]() 右側の楕円は動いています |
progJ.pdf の [#64] 対応部分を progJ-e.pdf に追加しました.
//App64.java
package myapp;
import java.awt.*;
class Fig64 extends Fig63 {
int x = 450;
public void paintComponent(Graphics g){
super.paintComponent(g);
try{Thread.sleep(100);}catch(Exception e){ }
/*-----------------------------
if(x > 300){
super.paintComponent(g);
g.setColor(Color.WHITE);
g.drawOval(150, 50, 100, 50);
g.setColor(Color.BLACK);
}//これはダメ
-----------------------------*/
x = (x + 5)%300; g.drawOval(x, 50, 100, 50);
repaint(x - 6, 49, 112, 52 );
}
}
public class App64 extends App61 {
App64( ){
super( ); p1.remove(f1);
f1 = new Fig64( ); p1.add(f1);
}
public static void main(String[ ] args) {
EventQueue.invokeLater(new Runnable( ) {
public void run( ) {new App64( );}
});
}
}