.


:




:

































 

 

 

 


. super this.




, Java new, , . , ( ), ( this). new , .

, , . , . , .

, . Dot Circle. Dot Circle , . , , ( ), . . , super ( superclass), . , ( ). , FilledCircle - Circle, .

 

package java_gui_example;

import java.awt.*;

 

public class FilledCircle extends Circle{

 

/** Creates a new instance of FilledCircle */

public FilledCircle(Graphics g,Color bgColor, int r,Color color) {

super(g,bgColor,r);

this.color=color;

}

 

public void show(){

Color oldC=graphics.getColor();

graphics.setColor(color);

graphics.setXORMode(bgColor);

graphics.fillOval(x,y,size,size);

graphics.setColor(oldC);

graphics.setPaintMode();

}

 

public void hide(){

Color oldC=graphics.getColor();

graphics.setColor(color);

graphics.setXORMode(bgColor);

graphics.fillOval(x,y,size,size);

graphics.setColor(oldC);

graphics.setPaintMode();

}}

, : , , Object, , , . super( ), , , .

. XOR ( ). setXORMode. . setPaintMode.

 

this , . - , . , . , Circle , x, y r :

Circle(Graphics g, Color bgColor){

graphics=g;

this.bgColor=bgColor;

size=(int)Math.round(Math.random()*40);

}

, x y, size , :

Circle(Graphics g, Color bgColor, int r){

this(g, bgColor);

size=r;

}

this , this .

C++ Java , .

( ):

- , ( ).

- .

- ( ), , , Object.

- , .

- .

- , .

- .

, - , , .

 

, . Java, , . :

 

class extends {

;

static {

}

 

{

}

 

- , ,

}

 

.

( main):

- ( );

- main;

- ;

- .

, main:

- ( );

- main;

- ;

- .

, ? , , : , . , , . , - , .





:


: 2017-02-28; !; : 660 |


:

:

- , , .
==> ...

1701 - | 1488 -


© 2015-2024 lektsii.org - -

: 0.013 .