Implement state machine on netbeans.