jbutton close jframe java

Java
private void btnButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
	this.dispose();
}
Source

Also in Java: