コード例 #1
0
ファイル: DockPanel.java プロジェクト: NoSuchProcess/geogebra
  /**
   * create the focus panel (composed of titleLabel, and, for EuclidianDockPanels, focus icon)
   *
   * @return the focus panel
   */
  protected JComponent createFocusPanel() {
    titleLabel = new JLabel(loc.getPlain(title));
    titleLabel.setFont(app.getPlainFont());
    titleLabel.setForeground(Color.darkGray);

    JPanel p = new JPanel(new FlowLayout(app.flowLeft(), 2, 1));

    if (app.getLocalization().isRightToLeftReadingOrder()) {
      p.add(titleLabel);
      p.add(Box.createHorizontalStrut(2));
      if (this.hasStyleBar) {
        p.add(this.toggleStyleBarButton);
      }
    } else {
      if (this.hasStyleBar) {
        p.add(this.toggleStyleBarButton);
      }
      p.add(Box.createHorizontalStrut(2));
      p.add(titleLabel);
    }
    return p;
  }
コード例 #2
0
ファイル: DockPanel.java プロジェクト: NoSuchProcess/geogebra
  /**
   * Bind this view to a dock manager. Also initializes the whole GUI as just at this point the
   * application is available.
   *
   * @param dockManager1 dock manager
   */
  public void register(DockManagerD dockManager1) {
    this.dockManager = dockManager1;
    setApp(dockManager1.getLayout().getApplication());
    // create buttons for the panels
    createButtons();

    // create button panel
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(app.flowRight(), 0, 1));
    if (app.getLocalization().isRightToLeftReadingOrder()) {
      buttonPanel.add(closeButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(windowButton);
      buttonPanel.add(unwindowButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(maximizeButton);
    } else {
      buttonPanel.add(maximizeButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(unwindowButton);
      buttonPanel.add(windowButton);
      buttonPanel.add(Box.createHorizontalStrut(4));
      buttonPanel.add(closeButton);
    }

    // Custom border for the major panels (title, stylebar and toolbar)
    Border panelBorder =
        BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 1, 0, SystemColor.controlShadow),
            BorderFactory.createEmptyBorder(0, 2, 0, 2));

    // create style bar panel
    styleBarPanel = new JPanel(new BorderLayout(1, 2));
    styleBarPanel.setBorder(panelBorder);
    styleBarPanel.addMouseListener(this);

    styleBarButtonPanel = new JPanel(new BorderLayout());
    JPanel p = new JPanel(new FlowLayout(0, 0, app.flowLeft()));
    if (this.hasStyleBar) {
      p.add(toggleStyleBarButton2);
    }
    p.add(Box.createHorizontalStrut(4));

    styleBarButtonPanel.add(p, BorderLayout.NORTH);
    styleBarPanel.add(styleBarButtonPanel, loc.borderWest());
    styleBarPanel.add(LayoutUtil.flowPanelRight(0, 0, 4, unwindowButton2), loc.borderEast());

    // construct the title panel and add all elements
    titlePanel = new JPanel();
    titlePanel.setBorder(panelBorder);
    titlePanel.setLayout(new BorderLayout());

    titlePanel.add(createFocusPanel(), loc.borderWest());
    titlePanel.add(buttonPanel, loc.borderEast());
    titlePanel.addMouseListener(this); // dragging to reconfigure
    titlePanel.addMouseListener(new MyButtonHider());

    // create toolbar panel
    if (hasToolbar()) {
      toolbarPanel = new JPanel(new BorderLayout());
      toolbarPanel.setBorder(panelBorder);
    }

    // construct a meta panel to hold the title, tool bar and style bar
    // panels

    JPanel titleBar = new JPanel(new BorderLayout());
    titleBar.add(styleBarPanel, BorderLayout.SOUTH);
    titleBar.add(titlePanel, BorderLayout.NORTH);

    JPanel metaPanel = new JPanel(new BorderLayout());
    metaPanel.add(titleBar, BorderLayout.SOUTH);
    if (hasToolbar()) metaPanel.add(toolbarPanel, BorderLayout.CENTER);

    // make titlebar visible if necessary
    updatePanel();

    add(metaPanel, BorderLayout.NORTH);
  }