很奇妙的分形图,佩服作者的想象力,我是在理解的基础上借鉴,Button做的很烂,呵呵!
很喜欢递归算法,我一定要原创一个给你们看看!
//KochSnowflake.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class KochSnowflake extends JApplet implements ActionListener {
private final int APPLET_WIDTH = 400;
private final int APPLET_HEIGHT = 440;
private final int MIN = 1, MAX = 9;
private JButton increase,decrease;
private JLabel titleLabel,orderLabel;
private KochPanel drawing;
private JPanel appletPanel,tools;
public void init() {
tools = new JPanel();
tools.setLayout(new BoxLayout(tools,BoxLayout.X_AXIS));
tools.setBackground(Color.yellow);
tools.setOpaque(true);
titleLabel = new JLabel("the koch snowflake");
titleLabel.setForeground(Color.black);
increase = new JButton("increase.gif");
increase.setPressedIcon(new ImageIcon("increasePressed.gif"));
increase.setMargin(new Insets(0,0,0,0));
&n