how to close a jframe in java with an if statement

Java
Jframe frame = new Jframe();
int count = 0;
if(count==10){
  frame.setVisable(false);
  frame.dispose();
}
Source

Also in Java: