Guest User

Untitled

a guest
Aug 28th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. import sign.signlink;
  2. import java.net.*;
  3. import java.awt.*;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.ActionEvent;
  6. import javax.swing.*;
  7. import javax.swing.plaf.metal.MetalLookAndFeel;
  8.  
  9.  
  10. public class Jframe extends client implements ActionListener {
  11.  
  12. private static JMenuItem menuItem;
  13. private JFrame frame;
  14.  
  15. public Jframe(String args[]) {
  16. super();
  17. try {
  18. sign.signlink.startpriv(InetAddress.getByName(server));
  19. initUI();
  20. } catch (Exception ex) {
  21. ex.printStackTrace();
  22. }
  23. }
  24.  
  25. public void initUI() {
  26. try {
  27. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  28. JPopupMenu.setDefaultLightWeightPopupEnabled(false);
  29. frame = new JFrame("Project Insanity");
  30. frame.setLayout(new BorderLayout());
  31. frame.setResizable(false);
  32. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  33. JPanel gamePanel = new JPanel();
  34.  
  35. gamePanel.setLayout(new BorderLayout());
  36. gamePanel.add(this);
  37. gamePanel.setPreferredSize(new Dimension(765, 503));
  38.  
  39. JMenu homeMenu = new JMenu("Home");
  40. JMenu forumMenu = new JMenu("Forums");
  41.  
  42. //String[] mainButtons = new String[] { "Project-Insanity.net", "-", "Exit" };
  43.  
  44. for (String name : mainButtons) {
  45. JMenuItem menuItem = new JMenuItem(name);
  46. if (name.equalsIgnoreCase("Home")) {
  47. openUpWebSite("http://www.project-insanity.net/");
  48. } else {
  49. if (name.equalsIgnoreCase("Forums")) {
  50. openUpWebSite("http://www.project-insanity.net/");
  51. }
  52. }
  53.  
  54. JMenuBar menuBar = new JMenuBar();
  55. JMenuBar jmenubar = new JMenuBar();
  56.  
  57. frame.add(jmenubar);
  58. menuBar.add(homeMenu);
  59. menuBar.add(forumsMenu);
  60. frame.getContentPane().add(menuBar, BorderLayout.NORTH);
  61. frame.getContentPane().add(gamePanel, BorderLayout.CENTER);
  62. frame.pack();
  63.  
  64. frame.setVisible(true); // can see the client
  65. frame.setResizable(false); // resizeable frame
  66.  
  67. init();
  68. } catch (Exception e) {
  69. e.printStackTrace();
  70. }
  71. }
  72.  
  73. public URL getCodeBase() {
  74. try {
  75. return new URL("http://" + server + "/cache");
  76. } catch (Exception e) {
  77. return super.getCodeBase();
  78. }
  79. }
  80.  
  81. public URL getDocumentBase() {
  82. return getCodeBase();
  83. }
  84.  
  85. public void loadError(String s) {
  86. System.out.println("loadError: " + s);
  87. }
  88.  
  89. public String getParameter(String key) {
  90. return "";
  91. }
  92.  
  93. private static void openUpWebSite(String url) {
  94. Desktop d = Desktop.getDesktop();
  95. try {
  96. d.browse(new URI(url));
  97. } catch (Exception e) {
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment