示例#1
0
 public void actionPerformed(ActionEvent arg0) {
   Fractal fractal = view.getFractal();
   if (fractal.getOrder() > 0) {
     fractal.setOrder(fractal.getOrder() - 1);
   }
   view.updateDrawing();
 }
示例#2
0
  private static void createAndShowGUI() {
    JFrame frame = new JFrame("Fractal");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    SpringLayout layout = new SpringLayout();
    frame.setLayout(layout);

    Orientation nw = new Orientation();
    nw.setOffset(0, 0);
    Orientation sw = new Orientation();
    sw.setOffset(0, regionSize);
    Orientation se = new Orientation();
    se.setOffset(regionSize, regionSize);

    Fractal fractal = new Fractal(regionSize);
    fractal.setOrientations(nw, sw, se);

    layout.putConstraint(SpringLayout.WEST, fractal, 5, SpringLayout.WEST, frame.getContentPane());
    layout.putConstraint(
        SpringLayout.NORTH, fractal, 5, SpringLayout.NORTH, frame.getContentPane());

    layout.putConstraint(SpringLayout.WEST, nw, 5, SpringLayout.EAST, fractal);
    layout.putConstraint(SpringLayout.NORTH, nw, 0, SpringLayout.NORTH, fractal);

    layout.putConstraint(SpringLayout.NORTH, sw, 5, SpringLayout.SOUTH, nw);
    layout.putConstraint(SpringLayout.WEST, sw, 0, SpringLayout.WEST, nw);

    layout.putConstraint(SpringLayout.NORTH, se, 5, SpringLayout.SOUTH, nw);
    layout.putConstraint(SpringLayout.WEST, se, 5, SpringLayout.EAST, sw);

    layout.putConstraint(
        SpringLayout.SOUTH, frame.getContentPane(), 5, SpringLayout.SOUTH, fractal);
    layout.putConstraint(SpringLayout.EAST, frame.getContentPane(), 5, SpringLayout.EAST, se);

    frame.add(nw);
    frame.add(sw);
    frame.add(se);

    frame.add(fractal);

    frame.setResizable(false);
    frame.pack();
    frame.setVisible(true);
  }