【Java开源代码栏目提醒】:本文主要为网学会员提供Cake.java,希望对需要Cake.java网友有所帮助,学习一下!
// Figure 9.18
import javax.swing.JComponent;
import java.awt.Graphics;
public abstract class Cake extends JComponent {
/** post: getX() == x and getY() == y
* and getWidth() == w and getHeight() == h
*/
public Cake( int x, int y, int w, int h) {
super();
setBounds(x, y, w, h);
}
/** post: a cake is drawn with lines for cutting into eighths */
public void paint( Graphics g ) {
paintCake(g);
paintEighthCuts(g);
paintChildren(g);
}
/** post: the cake is drawn */
protected abstract void paintCake( Graphics g );
/** post: the lines are drawn for cutting the cake into eighths */
protected abstract void paintEighthCuts( Graphics g );
}
上一篇:
Caesar.java
下一篇:
超市进销存管理系统的开发