Exemplo n.º 1
0
  private void go() {
    JFrame frame = new JFrame("Neural Particle Test");
    frame.getContentPane().setBackground(SColor.BLACK);
    TextCellFactory tcf = new TextCellFactory();
    tcf.font(new Font("Arial", Font.BOLD, 6));
    tcf.width(2);
    tcf.height(2);
    back = new SquidPanel(width, height, tcf, null);

    tcf.font(new Font("Arial", Font.BOLD, 26));
    tcf.width(20);
    tcf.height(20);
    front = new SquidPanel(width / 10, height / 10, tcf, null);

    JLayeredPane layers = new JLayeredPane();
    layers.setLayer(back, JLayeredPane.DEFAULT_LAYER);
    layers.setLayer(front, JLayeredPane.PALETTE_LAYER);
    layers.add(back);
    layers.add(front);
    layers.setPreferredSize(back.getPreferredSize());
    layers.setSize(back.getPreferredSize());

    frame.add(layers);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setVisible(true);

    frame.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
              back.erase();
              front.erase();
              back.refresh();
              front.refresh();
            } else {
              calculate();
            }
          }
        });

    //        calculate();
  }