Guest User

Jframe.java

a guest
Mar 4th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 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("DesolationX");
  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 fileMenu = new JMenu("DesolationX Information");
  40.  
  41. String[] mainButtons = new String[] { "DesolationX Client", "Version: 1.0", "-", "Forums", "-", "Exit DesolationX Client" };
  42. for (String name : mainButtons) {
  43. JMenuItem menuItem = new JMenuItem(name);
  44. if (name.equalsIgnoreCase("-")) {
  45. fileMenu.addSeparator();
  46. } else {
  47. menuItem.addActionListener(this);
  48. fileMenu.add(menuItem);
  49. }
  50. }
  51.  
  52. JMenuBar menuBar = new JMenuBar();
  53. JMenuBar jmenubar = new JMenuBar();
  54.  
  55. frame.add(jmenubar);
  56. menuBar.add(fileMenu);
  57. frame.getContentPane().add(menuBar, BorderLayout.NORTH);
  58. frame.getContentPane().add(gamePanel, BorderLayout.CENTER);
  59. frame.pack();
  60.  
  61. frame.setVisible(true); // can see the client
  62. frame.setResizable(false); // resizeable frame
  63.  
  64. init();
  65. } catch (Exception e) {
  66. e.printStackTrace();
  67. }
  68. }
  69.  
  70. public URL getCodeBase() {
  71. try {
  72. return new URL("http://" + server + "/cache");
  73. } catch (Exception e) {
  74. return super.getCodeBase();
  75. }
  76. }
  77.  
  78. public URL getDocumentBase() {
  79. return getCodeBase();
  80. }
  81.  
  82. public void loadError(String s) {
  83. System.out.println("loadError: " + s);
  84. }
  85.  
  86. public String getParameter(String key) {
  87. return "";
  88. }
  89.  
  90. private static void openUpWebSite(String url) {
  91. Desktop d = Desktop.getDesktop();
  92. try {
  93. d.browse(new URI(url));
  94. } catch (Exception e) {
  95. }
  96. }
  97.  
  98. public void actionPerformed(ActionEvent evt) {
  99. String cmd = evt.getActionCommand();
  100. try {
  101. if (cmd != null) {
  102. if (cmd.equalsIgnoreCase("Exit DesolationX Client")) {
  103. System.exit(0);
  104. }
  105. if (cmd.equalsIgnoreCase("Forums")) {
  106. openUpWebSite("http://www.DesolationXpk.com/");
  107. }
  108. }
  109. } catch (Exception e) {
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment