-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJframe.java
More file actions
executable file
·113 lines (94 loc) · 2.72 KB
/
Copy pathJframe.java
File metadata and controls
executable file
·113 lines (94 loc) · 2.72 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import sign.signlink;
import java.net.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
public class Jframe extends client implements ActionListener {
private static JMenuItem menuItem;
private JFrame frame;
public Jframe(String args[]) {
super();
try {
sign.signlink.startpriv(InetAddress.getByName(server));
initUI();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void initUI() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
frame = new JFrame("Project Insanity");
frame.setLayout(new BorderLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel gamePanel = new JPanel();
gamePanel.setLayout(new BorderLayout());
gamePanel.add(this);
gamePanel.setPreferredSize(new Dimension(765, 503));
JMenu fileMenu = new JMenu("Project Insanity");
String[] mainButtons = new String[] { "Remember to vote!", "-", "Exit" };
for (String name : mainButtons) {
JMenuItem menuItem = new JMenuItem(name);
if (name.equalsIgnoreCase("-")) {
fileMenu.addSeparator();
} else {
menuItem.addActionListener(this);
fileMenu.add(menuItem);
}
}
JMenuBar menuBar = new JMenuBar();
JMenuBar jmenubar = new JMenuBar();
frame.add(jmenubar);
menuBar.add(fileMenu);
frame.getContentPane().add(menuBar, BorderLayout.NORTH);
frame.getContentPane().add(gamePanel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true); // can see the client
frame.setResizable(false); // resizeable frame
init();
} catch (Exception e) {
e.printStackTrace();
}
}
public URL getCodeBase() {
try {
return new URL("http://" + server + "/cache");
} catch (Exception e) {
return super.getCodeBase();
}
}
public URL getDocumentBase() {
return getCodeBase();
}
public void loadError(String s) {
System.out.println("loadError: " + s);
}
public String getParameter(String key) {
return "";
}
private static void openUpWebSite(String url) {
Desktop d = Desktop.getDesktop();
try {
d.browse(new URI(url));
} catch (Exception e) {
}
}
public void actionPerformed(ActionEvent evt) {
String cmd = evt.getActionCommand();
try {
if (cmd != null) {
if (cmd.equalsIgnoreCase("exit")) {
System.exit(0);
}
if (cmd.equalsIgnoreCase("Project-Insanity.net")) {
openUpWebSite("http://www.project-insanity.net/");
}
}
} catch (Exception e) {
}
}
}