If you are trying to code for a event of a component then try code below. And make sure the class which this code is included is extended by Frame class
private void closeMouseClicked(java.awt.event.MouseEvent evt){
this.setState(1);
}
Or create an instance of a Frame class and call setState(1);