/net/minecraft/server/ServerGUI.java

https://bitbucket.org/agaricusb/mc-dev · Java · 93 lines · 75 code · 18 blank · 0 comment · 0 complexity · 416ae38f116e51de9a37be89ce6c0c56 MD5 · raw file

  1. package net.minecraft.server;
  2. import java.awt.BorderLayout;
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.util.logging.Logger;
  6. import javax.swing.JComponent;
  7. import javax.swing.JFrame;
  8. import javax.swing.JPanel;
  9. import javax.swing.JScrollPane;
  10. import javax.swing.JTextArea;
  11. import javax.swing.JTextField;
  12. import javax.swing.UIManager;
  13. import javax.swing.border.EtchedBorder;
  14. import javax.swing.border.TitledBorder;
  15. public class ServerGUI extends JComponent {
  16. public static Logger a = Logger.getLogger("Minecraft");
  17. private static boolean b = false;
  18. private DedicatedServer c;
  19. public static void a(DedicatedServer dedicatedserver) {
  20. try {
  21. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  22. } catch (Exception exception) {
  23. ;
  24. }
  25. ServerGUI servergui = new ServerGUI(dedicatedserver);
  26. b = true;
  27. JFrame jframe = new JFrame("Minecraft server");
  28. jframe.add(servergui);
  29. jframe.pack();
  30. jframe.setLocationRelativeTo((Component) null);
  31. jframe.setVisible(true);
  32. jframe.addWindowListener(new ServerWindowAdapter(dedicatedserver));
  33. }
  34. public ServerGUI(DedicatedServer dedicatedserver) {
  35. this.c = dedicatedserver;
  36. this.setPreferredSize(new Dimension(854, 480));
  37. this.setLayout(new BorderLayout());
  38. try {
  39. this.add(this.d(), "Center");
  40. this.add(this.b(), "West");
  41. } catch (Exception exception) {
  42. exception.printStackTrace();
  43. }
  44. }
  45. private JComponent b() {
  46. JPanel jpanel = new JPanel(new BorderLayout());
  47. jpanel.add(new GuiStatsComponent(this.c), "North");
  48. jpanel.add(this.c(), "Center");
  49. jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Stats"));
  50. return jpanel;
  51. }
  52. private JComponent c() {
  53. PlayerListBox playerlistbox = new PlayerListBox(this.c);
  54. JScrollPane jscrollpane = new JScrollPane(playerlistbox, 22, 30);
  55. jscrollpane.setBorder(new TitledBorder(new EtchedBorder(), "Players"));
  56. return jscrollpane;
  57. }
  58. private JComponent d() {
  59. JPanel jpanel = new JPanel(new BorderLayout());
  60. JTextArea jtextarea = new JTextArea();
  61. a.addHandler(new GuiLogOutputHandler(jtextarea));
  62. JScrollPane jscrollpane = new JScrollPane(jtextarea, 22, 30);
  63. jtextarea.setEditable(false);
  64. JTextField jtextfield = new JTextField();
  65. jtextfield.addActionListener(new ServerGuiCommandListener(this, jtextfield));
  66. jtextarea.addFocusListener(new ServerGuiFocusAdapter(this));
  67. jpanel.add(jscrollpane, "Center");
  68. jpanel.add(jtextfield, "South");
  69. jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat"));
  70. return jpanel;
  71. }
  72. static DedicatedServer a(ServerGUI servergui) {
  73. return servergui.c;
  74. }
  75. }