complete14_5.java
来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 37 行
JAVA
37 行
package questions.c14;
import javax.swing.*;
import java.awt.*;
public class Complete14_5 extends JApplet
implements Runnable {
public void init() {
getContentPane().add( new OvalPanel(),
BorderLayout.CENTER );
setSize( 450, 450 );
}
public void start() {
// your code here
}
public void stop() {
// your code here
}
public void run() {
// your code here
}
public class OvalPanel extends JPanel {
private final int MAX_DIAM = 150;
private int diameter = 10;
public void paintComponent( Graphics g ) {
super.paintComponent( g );
// erase by drawing in the background color
g.setColor( getBackground() );
g.fillOval( 200, 200, diameter, diameter );
// draw the new shape
g.setColor( Color.blue );
diameter += 10;
if ( diameter > MAX_DIAM ) {
diameter = 10;
}
g.fillOval( 200, 200, diameter, diameter );
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?