Java Reference
In-Depth Information
FIGURE 12.7 Several orders of the Koch snowflake
LISTING 12.6
//********************************************************************
// KochSnowflake.java Author: Lewis/Loftus
//
// Demonstrates the use of recursion.
//********************************************************************
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;
//-----------------------------------------------------------------
// Sets up the components for the applet.
//-----------------------------------------------------------------
public void init()
{
tools = new JPanel ();
tools.setLayout ( new BoxLayout(tools, BoxLayout.X_AXIS));
tools.setBackground (Color.yellow);
tools.setOpaque ( true );
Search WWH ::




Custom Search