Exemple #1
0
 void saveWindowLocations() {
   Window win = WindowManager.getWindow("B&C");
   if (win != null) Prefs.saveLocation(ContrastAdjuster.LOC_KEY, win.getLocation());
   win = WindowManager.getWindow("Threshold");
   if (win != null) Prefs.saveLocation(ThresholdAdjuster.LOC_KEY, win.getLocation());
   win = WindowManager.getWindow("Results");
   if (win != null) {
     Prefs.saveLocation(TextWindow.LOC_KEY, win.getLocation());
     Dimension d = win.getSize();
     Prefs.set(TextWindow.WIDTH_KEY, d.width);
     Prefs.set(TextWindow.HEIGHT_KEY, d.height);
   }
   win = WindowManager.getWindow("Log");
   if (win != null) {
     Prefs.saveLocation(TextWindow.LOG_LOC_KEY, win.getLocation());
     Dimension d = win.getSize();
     Prefs.set(TextWindow.LOG_WIDTH_KEY, d.width);
     Prefs.set(TextWindow.LOG_HEIGHT_KEY, d.height);
   }
   win = WindowManager.getWindow("ROI Manager");
   if (win != null) Prefs.saveLocation(RoiManager.LOC_KEY, win.getLocation());
 }
 public static Window setSize(JComponent content, final Dimension size) {
   final Window popupWindow = SwingUtilities.windowForComponent(content);
   final Point location = popupWindow.getLocation();
   popupWindow.setLocation(location.x, location.y);
   Insets insets = content.getInsets();
   if (insets != null) {
     size.width += insets.left + insets.right;
     size.height += insets.top + insets.bottom;
   }
   content.setPreferredSize(size);
   popupWindow.pack();
   return popupWindow;
 }
Exemple #3
0
  /** Installs the sheet on the owner. This method is invoked just before the JSheet is shown. */
  protected void installSheet() {
    if (!isNativeSheetSupported() && !isInstalled && isExperimentalSheet()) {
      Window owner = getOwner();
      if (owner != null) {
        owner.addWindowListener(windowEventHandler);
      }
      isInstalled = true;
    } else {
      Window owner = getOwner();
      if (owner != null) {

        // Determine the location for the sheet and its owner while
        // the sheet will be visible.
        // In case we have to shift the owner to fully display the
        // dialog, we remember the shift back position.
        Point ownerLoc = owner.getLocation();
        Point sheetLoc;
        if (isShowAsSheet()) {
          if (owner instanceof JFrame) {
            sheetLoc =
                new Point(
                    ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                    ownerLoc.y
                        + owner.getInsets().top
                        + ((JFrame) owner).getRootPane().getContentPane().getY());
          } else if (owner instanceof JDialog) {
            sheetLoc =
                new Point(
                    ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                    ownerLoc.y
                        + owner.getInsets().top
                        + ((JDialog) owner).getRootPane().getContentPane().getY());
          } else {
            sheetLoc =
                new Point(
                    ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                    ownerLoc.y + owner.getInsets().top);
          }

          if (sheetLoc.x < 0) {
            owner.setLocation(ownerLoc.x - sheetLoc.x, ownerLoc.y);
            sheetLoc.x = 0;
            shiftBackLocation = ownerLoc;
            oldLocation = owner.getLocation();
          } else {
            shiftBackLocation = null;
            oldLocation = ownerLoc;
          }
        } else {
          sheetLoc =
              new Point(
                  ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
                  ownerLoc.y + (owner.getHeight() - getHeight()) / 2);
        }
        setLocation(sheetLoc);

        oldFocusOwner = owner.getFocusOwner();

        // Note: We mustn't change the windows focusable state because
        // this also affects the focusable state of the JSheet.
        // owner.setFocusableWindowState(false);
        owner.setEnabled(false);
        // ((JFrame) owner).setResizable(false);
        if (isShowAsSheet()) {
          owner.addComponentListener(ownerMovementHandler);
        } else {
          if (owner instanceof Frame) {
            setTitle(((Frame) owner).getTitle());
          }
        }
      }
      isInstalled = true;
    }
  }