import javax.swing.*;
import java.awt.event.ActionEvent;

import snow.*;

public class HelloWorld {
    /** submit counter */
    private int clicks;
    
    /** JTextField member; gets injected by Snow (look for :id tf in the Lisp file) */
    private JTextField tf;
    
    /** Jlabel to display number of button clicks */
    private JLabel cnt;

    /**
     * Event handler.
     * Appends a '#' to the textfields content and increments the number of
     * clicks displayed by the label.
     */   
    public void submit(ActionEvent e) {
	tf.setText(tf.getText() + '#');
	cnt.setText(String.valueOf( ++clicks ));
    }

    /** Renders UI at construction */
    private HelloWorld() throws Exception {
	Snowlet s = Snow.getInterpretedSnowlet(getClass().getResource("helloworld_j.lisp"));
	s.setBackingBean(this);
	s.eval();
    }

    /** Makes the class bootable */
    public static void main( String[] args ) throws Exception {
	new HelloWorld();
    }

    public JTextField getTf() {
	return tf;
    }

    public void setTf(JTextField tf) {
	this.tf = tf;
    }

    public JLabel getCnt() {
	return cnt;
    }

    public void setCnt(JLabel cnt) {
	this.cnt = cnt;
    }

}
