summaryrefslogtreecommitdiffstats
path: root/source/client/swing/ZApplet.java
blob: 0ecd92acb9ad5624c0d34835773690f14de5149c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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();
	}
}