Java面向对象编程(随书配套源代码)
阐述了面向对象编程的思想
源代码在线查看: example1.java
package chapter15;
import javax.swing.*;
import java.awt.*;
public class example1 extends JApplet
{
int initCounter=0;
int startCounter=0;
int stopCounter=0;
int destroyCounter=0;
public void paint(Graphics g)
{
g.drawString("init : "+initCounter, 20, 20);
g.drawString("start : "+initCounter, 20, 35);
g.drawString("stop : "+initCounter, 20, 50);
g.drawString("destroy : "+initCounter, 20, 65);
}
public void init()
{
initCounter++;
repaint();
}
public void start()
{
startCounter++;
repaint();
}
public void stop()
{
stopCounter++;
repaint();
}
public void destroy()
{
destroyCounter++;
repaint();
}
}