package itunes.client.swing; import javax.swing.*; import java.awt.event.*; public class ZApplet extends JApplet { private ZPlayer app; public void init() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JButton jb = new JButton("Launch ZPlayer"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { createNewPlayer(); } }); this.getContentPane().add(jb); } public void createNewPlayer() { if(app == null) { app = new ZPlayer(true); app.frame.addWindowListener(new WindowListener() { public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { app = null; } public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowActivated(WindowEvent e) {} public void windowDeactivated(WindowEvent e) {} public void windowOpened(WindowEvent e) {} }); app.connectToHost(getParameter("host")); } else { app.frame.toFront(); } } public void stop() { app.logOut(); } }