import java.applet.Applet ;
import java.awt.Graphics ;
import java.awt.Color ;
import java.awt.Image ;
import java.awt.Dimension ;
/* <applet code="Main.class" width="500" height="500"></applet> */
class ForDimChange {
private int x, y;
ForDimChange( ) {
x = y = 0 ;
update( ) ;
}
void update( ) {
boolean flag = false ;
dim = getSize( ) ;
if ( x != dim.width ) {
x = dim.width ;
flag = true ;
}
if ( y != dim.height ) {
y = dim.height ;
flag = true ;
}
if ( flag) {
buff = createImage( x, y) ;
ct = buff.getGraphics ( ) ;
}
}
int get_dimx( ) { return x; }
int get_dimy( ) { return y; }
Image get_buff
( ) { return buff
; } }
boolean chkx = true , chky = true ;
int x = 250 , y = 140 ;
ForDimChange fdc;
class ForDimChange {
private int x, y;
ForDimChange( ) {
x = y = 0 ;
update( ) ;
}
void update( ) {
boolean flag = false ;
dim = getSize( ) ;
if ( x != dim.width ) {
x = dim.width ;
flag = true ;
}
if ( y != dim.height ) {
y = dim.height ;
flag = true ;
}
if ( flag) {
buff = createImage( x, y) ;
ct = buff.getGraphics ( ) ;
}
}
int get_dimx( ) { return x; }
int get_dimy( ) { return y; }
Image get_buff
( ) { return buff
; } }
public void init( ) {
fdc = new ForDimChange( ) ;
th.start ( ) ;
}
public void run( ) {
try {
while ( true ) {
fdc.update ( ) ;
if ( chkx) x++; else x--;
if ( chky) y++; else y--;
if ( x == fdc.get_dimx ( ) ) chkx = false ;
if ( x == 0 ) chkx = true ;
if ( y == fdc.get_dimy ( ) ) chky = false ;
if ( y == 0 ) chky = true ;
repaint( ) ;
}
}
paint( g) ;
}
ct = fdc.get_ct ( ) ;
ct.
setColor ( Color .
white ) ; ct.fillRect ( 0 , 0 , fdc.get_dimx ( ) , fdc.get_dimy ( ) ) ;
ct.fillRect ( x, y, 20 , 20 ) ;
g.drawImage ( fdc.get_buff ( ) , 0 , 0 , this ) ;
}
}
/* end */
aW1wb3J0IGphdmEuYXBwbGV0LkFwcGxldDsKaW1wb3J0IGphdmEuYXd0LkdyYXBoaWNzOwppbXBv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oLnN0YXJ0KCk7CiAgfQoKICBwdWJsaWMgdm9pZCBydW4oKSB7CiAgICB0cnkgewogICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgIGZkYy51cGRhdGUoKTsKICAgICAgICBpZiAoY2hreCkgeCsrOyBlbHNlIHgtLTsKICAgICAgICBpZiAoY2hreSkgeSsrOyBlbHNlIHktLTsKICAgICAgICBpZiAoeCA9PSBmZGMuZ2V0X2RpbXgoKSkgY2hreCA9IGZhbHNlOwogICAgICAgIGlmICh4ID09IDApIGNoa3ggPSB0cnVlOwogICAgICAgIGlmICh5ID09IGZkYy5nZXRfZGlteSgpKSBjaGt5ID0gZmFsc2U7CiAgICAgICAgaWYgKHkgPT0gMCkgY2hreSA9IHRydWU7CgogICAgICAgIHJlcGFpbnQoKTsKICAgICAgICBUaHJlYWQuc2xlZXAoMTApOwogICAgICB9CiAgICB9IGNhdGNoIChJbnRlcnJ1cHRlZEV4Y2VwdGlvbiBlKSB7IH07CiAgfQogIHB1YmxpYyB2b2lkIHVwZGF0ZShHcmFwaGljcyBnKSB7CiAgICBwYWludChnKTsKICB9CiAgcHVibGljIHZvaWQgcGFpbnQoR3JhcGhpY3MgZykgewogICAgR3JhcGhpY3MgY3Q7CiAgICBjdCA9IGZkYy5nZXRfY3QoKTsKICAgIGN0LnNldENvbG9yKENvbG9yLndoaXRlKTsKICAgIGN0LmZpbGxSZWN0KDAsIDAsIGZkYy5nZXRfZGlteCgpLCBmZGMuZ2V0X2RpbXkoKSk7CiAgICBjdC5zZXRDb2xvcihDb2xvci5yZWQpOwogICAgY3QuZmlsbFJlY3QoeCwgeSwgMjAsIDIwKTsKICAgIGcuZHJhd0ltYWdlKGZkYy5nZXRfYnVmZigpLCAwLCAwLCB0aGlzKTsKICB9Cn0KLyogZW5kICovCg==
compilation info
Main.java:20: cannot find symbol
symbol : method getSize()
location: class ForDimChange
dim = getSize();
^
Main.java:30: cannot find symbol
symbol : method createImage(int,int)
location: class ForDimChange
buff = createImage(x, y);
^
2 errors
stdout