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