private void setLocation() {
   if (app.getGuiManager().showView(App.VIEW_DATA_ANALYSIS)) {
     setLocationRelativeTo(
         ((DataAnalysisViewD) app.getGuiManager().getDataAnalysisView())
             .getDataAnalysisViewComponent());
   } else {
     setLocationRelativeTo(app.getMainComponent());
   }
 }
Beispiel #2
0
  /**
   * Create a frame for this DockPanel. The frame will either be a JFrame or a JDialog depending on
   * the isDialog flag.
   */
  public void createFrame() {

    if (isDialog) {
      frame =
          new JDialog(app.getFrame(), false) {
            private static final long serialVersionUID = 1L;

            // Send window closing event when dialog is set invisible.
            // This allows a dock panel view to close properly.
            @Override
            public void setVisible(boolean isVisible) {
              if (!isVisible && frame != null) {
                windowClosing(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
              }
              super.setVisible(isVisible);
            }
          };
    } else {
      frame = new JFrame(getPlainTitle());
      // needs the higher res as used by Windows 7 for the Toolbar
      ((JFrame) frame).setIconImage(app.getInternalImage("geogebra64.png"));
    }

    frame.addWindowListener(this);

    frame.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent event) {
            setFrameBounds(event.getComponent().getBounds());
          }

          @Override
          public void componentMoved(ComponentEvent event) {
            setFrameBounds(event.getComponent().getBounds());
          }
        });

    if (isDialog) {
      (((JDialog) frame).getContentPane()).add(this);
    } else {
      (((JFrame) frame).getContentPane()).add(this);
      menubar = loadMenuBar();
      if (menubar != null) {
        ((JFrame) frame).setJMenuBar(menubar);
      }
    }

    // TODO multimonitor supported?
    Rectangle screenSize =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();

    // Use the previous dimension of this view
    Rectangle windowBounds = getFrameBounds();

    // resize window if necessary
    if (windowBounds.width > screenSize.width) windowBounds.width = screenSize.width - 50;
    if (windowBounds.height > screenSize.height) windowBounds.height = windowBounds.height - 50;

    // center window if necessary
    if (isNewDialog) {
      // frame.pack();
      frame.setSize(windowBounds.getSize());
      frame.setLocationRelativeTo(app.getMainComponent());
      isNewDialog = false;
    } else if (windowBounds.x + windowBounds.width > screenSize.width
        || windowBounds.y + windowBounds.height > screenSize.height) {
      frame.setLocationRelativeTo(null);

    } else {
      frame.setLocation(windowBounds.getLocation());
    }
    setOpenInFrame(true);

    frame.setSize(windowBounds.getSize());
    frame.setVisible(true);

    // make titlebar visible if necessary
    updatePanel();

    frame.repaint();
  }