예제 #1
0
 public static void createAndShowGUI() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (ClassNotFoundException
       | InstantiationException
       | IllegalAccessException
       | UnsupportedLookAndFeelException ex) {
     ex.printStackTrace();
   }
   JFrame frame = new JFrame("@title@");
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.getContentPane().add(new MainPanel());
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #2
0
  public void initUI() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      JPopupMenu.setDefaultLightWeightPopupEnabled(false);
      frame = new JFrame("Project Benelux | 317 | Fullscreen - Resizeable");
      frame.setLayout(new BorderLayout());
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      gamePanel = new JPanel();
      new AutoUpdater().run();
      webclient = false;
      gamePanel.setLayout(new BorderLayout());
      gamePanel.add(this);
      JMenu fileMenu = new JMenu("File");

      String[] mainButtons = new String[] {"-", "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();
      Dimension dimension1 = new Dimension(765 + 16, 503 + 59);
      frame.setMinimumSize(dimension1);
      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(true); // resizeable frame
      init();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #3
0
  // Main method
  public static void main(String[] args) {
    int qcom_qix = 0;

    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (args.length > 0) {
      System.out.println("Queue : " + args[0]);
      try {
        qcom_qix = Integer.parseInt(args[0]);
      } catch (NumberFormatException e) {
        System.out.println("Syntax error in que number");
        qcom_qix = 0;
      }
    }
    // new Gdh( (Object) null);
    new JopSpider(qcom_qix);
  }
 /** Applet initialization */
 public void init() {
   // Get the port to be used
   String port_str = getParameter("port");
   if (port_str != null) {
     port = Integer.parseInt(port_str);
   }
   // Try to use the system look and feel
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
   }
   // Create main panel to hold notebook
   main_panel = new JPanel();
   main_panel.setBackground(Color.white);
   main_panel.setLayout(new BorderLayout());
   setContentPane(main_panel);
   // Create the notebook
   tabbed_pane = new JTabbedPane(JTabbedPane.TOP);
   main_panel.add(tabbed_pane, BorderLayout.CENTER);
   // Add notebook page for default host connection
   pages = new Vector();
   addPage(new SOAPMonitorPage(getCodeBase().getHost()));
 }
예제 #5
0
 private static void initGui() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception exception) {
     exception.printStackTrace();
   }
   JFrame frame = new JFrame("DarkBot");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLayout(new GridBagLayout());
   Insets noInsets = new Insets(0, 0, 0, 0);
   final JToggleButton sessionsButton = new JToggleButton("Login (0)");
   frame.add(
       sessionsButton,
       new GridBagConstraints(
           0, 0, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   sessionsButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           sessions.set(sessionsButton.isSelected());
           synchronized (sessions) {
             sessions.notifyAll();
           }
         }
       });
   final JToggleButton joinsButton = new JToggleButton("Join (0)");
   frame.add(
       joinsButton,
       new GridBagConstraints(
           0, 1, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   joinsButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           joins.set(joinsButton.isSelected());
           synchronized (joins) {
             joins.notifyAll();
           }
         }
       });
   final JTextField field = new JTextField();
   frame.add(
       field,
       new GridBagConstraints(
           0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   final JButton button = new JButton("Start");
   frame.add(
       button,
       new GridBagConstraints(
           1, 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, noInsets, 0, 0));
   button.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           if (button.getText().startsWith("Start")) {
             field.setEnabled(false);
             spamMessage = field.getText();
             button.setText("Stop");
           } else {
             spamMessage = null;
             button.setText("Start");
             field.setEnabled(true);
           }
         }
       });
   Timer timer =
       new Timer(
           500,
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
               sessionsButton.setText(
                   sessionsButton.getText().split(" ")[0]
                       + " ("
                       + Integer.toString(sessionCount.get())
                       + ")");
               joinsButton.setText(
                   joinsButton.getText().split(" ")[0]
                       + " ("
                       + Integer.toString(amountJoined.get())
                       + ")");
             }
           });
   timer.setRepeats(true);
   timer.start();
   frame.pack();
   frame.setSize(500, frame.getHeight());
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #6
0
  /** Initializes the applet SVGApplet */
  public void init() {
    // Set look and feel
    // -----------------
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Throwable e) {
      // Do nothing.
      // If we can't set the desired look and feel, UIManager does
      // automaticaly the right thing for us.
    }

    // Display copyright info while we are loading the data
    // ----------------------------------------------------
    Container c = getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
    String[] labels = getAppletInfo().split("\n"); // Strings.split(getAppletInfo(), '\n');
    for (int i = 0; i < labels.length; i++) {
      c.add(new JLabel((labels[i].length() == 0) ? " " : labels[i]));
    }

    // We load the data using a worker thread
    // --------------------------------------
    new Worker() {

      public Object construct() {
        Object result = null;

        InputStream in = null;
        try {
          // Try to read the data using all known input formats.
          Drawing drawing = createDrawing();
          for (InputFormat fmt : drawing.getInputFormats()) {
            try {
              if (getParameter("data") != null) {
                in = new ByteArrayInputStream(getParameter("data").getBytes("UTF8"));
              } else if (getParameter("datafile") != null) {
                URL url = new URL(getDocumentBase(), getParameter("datafile"));
                in = url.openConnection().getInputStream();
              }
              if (in != null) {
                fmt.read(in, drawing);
                result = drawing;
                break;
              }
            } catch (IOException e) {
              result = e;
            }
          }
        } catch (Throwable t) {
          result = t;
        } finally {
          if (in != null) {
            try {
              in.close();
            } catch (IOException ex) {
              // ignore
            }
          }
        }
        return result;
      }

      public void finished(Object result) {
        if (result instanceof Throwable) {
          ((Throwable) result).printStackTrace();
        }
        Container c = getContentPane();
        c.setLayout(new BorderLayout());
        c.removeAll();
        c.add(drawingPanel = new SVGDrawingPanel());

        initComponents();
        if (result != null) {
          if (result instanceof Drawing) {
            setDrawing((Drawing) result);
          } else if (result instanceof Throwable) {
            getDrawing().add(new SVGTextFigure(result.toString()));
            ((Throwable) result).printStackTrace();
          }
        }

        c.validate();
      }
    }.start();
  }
예제 #7
0
  public void initUI() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      JPopupMenu.setDefaultLightWeightPopupEnabled(false);
      frame = new JFrame("Vestige-x Developers Client");
      frame.setIconImage(
          Toolkit.getDefaultToolkit().getImage(signlink.findcachedir() + "Cursor.png"));
      frame.setLayout(new BorderLayout());
      frame.setResizable(false);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JPanel gamePanel = new JPanel();
      gamePanel.setLayout(new BorderLayout());
      gamePanel.add(this);
      Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
      int w = 765;
      int h = 503;
      int x = (dim.width - w) / 2;
      int y = (dim.height - h) / 2;
      frame.setLocation(x, y);
      gamePanel.setPreferredSize(new Dimension(765, 503));
      JMenu fileMenu = new JMenu("  File  ");
      JMenu toolMenu = new JMenu("  Tools  ");
      JMenu infoMenu = new JMenu("  Info  ");
      JMenu toggleMenu = new JMenu("  Toggles  ");
      JMenu profileMenu = new JMenu("  Links  ");
      JButton shotMenu = new JButton("Take Screenshot");
      shotMenu.setActionCommand("Screenshot");
      shotMenu.addActionListener(this);
      String[] mainButtons = new String[] {"View Images", "Exit"};
      String[] toolButtons = new String[] {"World Map"};
      String[] infoButtons = new String[] {"Client Information", "Support"};
      String[] toggleButtons = new String[] {"Toggle 10x Damage", "Untoggle 10x Damage"};
      String[] profileButtons =
          new String[] {"Donate", "Vote", "-", "Highscores", "Guides", "YouTube", "Forums"};

      for (String name : mainButtons) {
        JMenuItem menuItem = new JMenuItem(name);
        if (name.equalsIgnoreCase("-")) {
          fileMenu.addSeparator();
        } else {
          menuItem.addActionListener(this);
          fileMenu.add(menuItem);
        }
      }
      for (String name : toolButtons) {
        JMenuItem menuItem = new JMenuItem(name);
        if (name.equalsIgnoreCase("-")) toolMenu.addSeparator();
        else {
          menuItem.addActionListener(this);
          toolMenu.add(menuItem);
        }
      }

      for (String name : infoButtons) {
        JMenuItem menuItem = new JMenuItem(name);
        if (name.equalsIgnoreCase("-")) infoMenu.addSeparator();
        else {
          menuItem.addActionListener(this);
          infoMenu.add(menuItem);
        }
      }
      for (String name : toggleButtons) {
        JMenuItem menuItem = new JMenuItem(name);
        if (name.equalsIgnoreCase("-")) toggleMenu.addSeparator();
        else {
          menuItem.addActionListener(this);
          toggleMenu.add(menuItem);
        }
      }
      for (String name : profileButtons) {
        JMenuItem menuItem = new JMenuItem(name);
        if (name.equalsIgnoreCase("-")) toggleMenu.addSeparator();
        else {
          menuItem.addActionListener(this);
          profileMenu.add(menuItem);
        }
      }
      JMenuBar menuBar = new JMenuBar();
      JMenuBar jmenubar = new JMenuBar();

      frame.add(jmenubar);
      menuBar.add(fileMenu);
      menuBar.add(toolMenu);
      menuBar.add(infoMenu);
      // menuBar.add(toggleMenu);
      menuBar.add(profileMenu);
      menuBar.add(shotMenu);
      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();
    }
  }
예제 #8
0
  /**
   * Displays a progress indicator and then invokes <code>loadDrawing</code> on a worker thread.
   * Displays the drawing panel when done successfully. Displays an error message when done
   * unsuccessfully.
   *
   * @see #loadDrawing
   */
  @Override
  public final void init() {
    // set the language of the applet
    if (getParameter("Locale") != null) {
      Locale.setDefault(new Locale(getParameter("Locale")));
    }

    final ResourceBundleUtil labels =
        ResourceBundleUtil.getBundle("org.jhotdraw.samples.svg.Labels");

    // Set look and feel
    // -----------------
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Throwable e) {
      // Do nothing.
      // If we can't set the desired look and feel, UIManager does
      // automaticaly the right thing for us.
    }

    // Set our own popup factory, because the one that comes with Mac OS X
    // creates translucent popups which is not useful for color selection
    // using pop menus.
    try {
      PopupFactory.setSharedInstance(new PopupFactory());
    } catch (Throwable e) {
      // If we can't set the popup factory, we have to use what is there.
    }

    // Display a progress indicator while we are loading the drawing
    // ----------------------------------------------------------
    Container c = getContentPane();
    final ProgressIndicator progress =
        new ProgressIndicator(getName(), labels.getString("progressInitializing"));
    c.add(progress);
    progress.revalidate();

    // Load the drawing using a worker thread
    // --------------------------------------
    new Worker<Drawing>() {

      @Override
      protected Drawing construct() throws Exception {
        Thread t =
            new Thread() {

              @Override
              public void run() {
                try {
                  drawingComponent = createDrawingComponent();
                } catch (Throwable t) {
                  t.printStackTrace();
                }
              }
            };
        t.start();
        try {
          progress.setNote(labels.getString("progressLoading"));
          Drawing drawing = loadDrawing(progress);
          progress.setNote(labels.getString("progressOpeningEditor"));
          progress.setIndeterminate(true);
          return drawing;
        } finally {
          t.join();
        }
      }

      @Override
      protected void done(Drawing result) {
        Container c = getContentPane();
        c.removeAll();
        c.setLayout(new BorderLayout());
        c.add(drawingComponent.getComponent());
        initComponents();
        if (result != null) {
          setDrawing(result);
        }
        drawingComponent.revalidate();
        ((JComponent) c).revalidate();
      }

      @Override
      protected void failed(Throwable error) {
        Drawing d = createDrawing();
        String message = (error.getMessage() == null) ? error.toString() : error.getMessage();
        SVGTextAreaFigure txt =
            new SVGTextAreaFigure(
                labels.getFormatted("messageLoadFailed", getParameter("DrawingURL"), message));
        txt.setBounds(new Point2D.Double(0, 0), new Point2D.Double(getWidth(), getHeight()));
        d.add(txt);
        done(d);
        /*
        Container c = getContentPane();
        c.setLayout(new BorderLayout());
        c.removeAll();
        Throwable error = result;
        error.printStackTrace();
        String message = (error.getMessage() == null) ? error.toString() : error.getMessage();
        MessagePanel mp = new MessagePanel(
        UIManager.getIcon("OptionPane.errorIcon"),
        labels.getFormatted("messageLoadFailed", htmlencode(getParameter("DrawingURL")), htmlencode(message)));
        c.add(mp);
        mp.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
        if ("close".equals(evt.getActionCommand())) {
        close();
        }
        }
        });
        mp.revalidate();
        */
      }

      @Override
      protected void finished() {
        long end = System.currentTimeMillis();
        System.out.println("AbstractDrawingApplet startup latency:" + (end - start));
      }
    }.start();
  }