Frame f = new Frame("Close Me"); f.add(new Label("Try Titlebar Close", Label.CENTER)); f.setSize(100, 100); f.setVisible(true); f.addWindowListener(new WindowCloser(f, true));