Exemplo n.º 1
0
  private void construct() {
    setTitle("JPokemon (ver 0.1)");
    setIconImage(Tools.findImage("main-icon"));
    setSize(720, 457); // WIDTH, HEIGHT
    setUndecorated(true);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    // Using JLayeredPane so my buttons can sit on the picture
    p = new JLayeredPane();
    ImageIcon bg;
    // Add Splash
    if (pref.getBoolean("beat", false)) bg = new ImageIcon(Tools.findImage("splashalt"));
    else bg = new ImageIcon(Tools.findImage("splash"));
    s.setIcon(bg);
    s.setBounds(10, 10, 700, 437);
    p.add(s, new Integer(-1));

    // Load Button
    LoadButton l = new LoadButton(this);
    l.setBounds(550, 100, 110, 30); // 10px border on all sides
    p.add(l, new Integer(0));

    // New Game Button
    NewButton n = new NewButton(this);
    n.setBounds(550, 60, 110, 30);
    p.add(n, new Integer(0));

    // Exit Game Button
    QuitButton q = new QuitButton(this);
    q.setBounds(550, 140, 110, 30);
    p.add(q, new Integer(0));

    // OPTIONAL: Reset Splash logon
    if (pref.getBoolean("beat", false)) {
      r = new ResetButton();
      r.setBounds(550, 180, 110, 30);
      p.add(r, new Integer(0));
    }
    add(p);

    setLocationRelativeTo(null);
  }
Exemplo n.º 2
0
  /**
   * Sets the window title pane -- the JComponent used to provide a plaf a way to override the
   * native operating system's window title pane with one whose look and feel are controlled by the
   * plaf. The plaf creates and sets this value; the default is null, implying a native operating
   * system window title pane.
   *
   * @param content the <code>JComponent</code> to use for the window title pane.
   */
  private void setTitlePane(JRootPane root, JComponent titlePane) {
    JLayeredPane layeredPane = root.getLayeredPane();
    JComponent oldTitlePane = getTitlePane();

    if (oldTitlePane != null) {
      oldTitlePane.setVisible(false);
      layeredPane.remove(oldTitlePane);
    }
    if (titlePane != null) {
      layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
      titlePane.setVisible(true);
    }
    this.titlePane = titlePane;
  }
Exemplo n.º 3
0
 /**
  * This method adds the panels to the window and organises them using a GridBagLayout and a
  * JLayeredPane.
  */
 private void populateFrame(Container frame) {
   frame.setLayout(new GridBagLayout());
   GridBagConstraints layoutConstraints = new GridBagConstraints();
   JLayeredPane dungeonArea = new JLayeredPane();
   dungeonArea.setPreferredSize(new Dimension(448, 448));
   dungeonArea.add(dungeonPanel, JLayeredPane.DEFAULT_LAYER);
   // the DungeonPanel is added underneath
   dungeonArea.add(dungeonPanelOverlay, JLayeredPane.PALETTE_LAYER);
   // the mostly transparent DungeonPanelOverlay is added on top in the same position
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 0;
   layoutConstraints.gridwidth = 7;
   layoutConstraints.gridheight = 7;
   frame.add(dungeonArea, layoutConstraints);
   layoutConstraints.gridx = 7;
   layoutConstraints.gridwidth = 1;
   frame.add(serverSettings, layoutConstraints);
   layoutConstraints.gridx = 0;
   layoutConstraints.gridy = 7;
   layoutConstraints.gridwidth = 8;
   layoutConstraints.gridheight = 1;
   frame.add(chatPanel, layoutConstraints);
 }