コード例 #1
0
  private void addMenuItems(JMenu menu) {
    menu.add(myRestoreAction);
    menu.add(myIconifyAction);
    if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
      menu.add(myMaximizeAction);
    }

    menu.add(new JSeparator());

    menu.add(myCloseAction);
  }
コード例 #2
0
    public void layoutContainer(Container c) {
      int w = getWidth();
      int h = getHeight();
      int x;
      int spacing;
      int buttonHeight;
      int buttonWidth;

      if (myCloseButton != null && myCloseButton.getIcon() != null) {
        buttonHeight = myCloseButton.getIcon().getIconHeight();
        buttonWidth = myCloseButton.getIcon().getIconWidth();
      } else {
        buttonHeight = IMAGE_HEIGHT;
        buttonWidth = IMAGE_WIDTH;
      }

      spacing = 5;
      x = spacing;
      if (myMenuBar != null) {
        myMenuBar.setBounds(x, (h - buttonHeight) / 2, buttonWidth, buttonHeight);
      }

      if (myIdeMenu != null) {
        final Dimension size = myIdeMenu.getPreferredSize();

        x += spacing + (myMenuBar != null ? buttonWidth : 0);

        myIdeMenu.setBounds(x, (h - size.height) / 2, size.width, size.height);
      }

      x = w;
      spacing = 8;
      x += -spacing - buttonWidth;
      if (myCloseButton != null) {
        myCloseButton.setBounds(x, (h - buttonHeight) / 2, buttonWidth, buttonHeight);
      }

      if (getWindowDecorationStyle() == JRootPane.FRAME) {
        if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
          if (myToggleButton.getParent() != null) {
            // spacing = 10;
            x += -spacing - buttonWidth;
            myToggleButton.setBounds(x, (h - buttonHeight) / 2, buttonWidth, buttonHeight);
          }
        }

        if (myIconifyButton != null && myIconifyButton.getParent() != null) {
          x += -spacing - buttonWidth;
          myIconifyButton.setBounds(x, (h - buttonHeight) / 2, buttonWidth, buttonHeight);
        }
      }
    }