JFrame f = new JFrame("HelloJava2");
// Make the application exit when the window is closed.
f.addWindowListener(new WindowAdapter( ) {
public void windowClosing(WindowEvent we) { System.exit(0); }
});
f.setSize(300, 300);
f.getContentPane( ).add(new HelloJava2("Hello, Java!"));
f.setVisible(true);