コード例 #1
1
  protected void resizeDesktop() {
    int x = 0;
    int y = 0;
    JScrollPane scrollPane = getScrollPane();
    Insets scrollInsets = getScrollPaneInsets();

    if (scrollPane != null) {
      JInternalFrame allFrames[] = desktop.getAllFrames();
      for (int i = 0; i < allFrames.length; i++) {
        if (allFrames[i].getX() + allFrames[i].getWidth() > x) {
          x = allFrames[i].getX() + allFrames[i].getWidth();
        }
        if (allFrames[i].getY() + allFrames[i].getHeight() > y) {
          y = allFrames[i].getY() + allFrames[i].getHeight();
        }
      }
      Dimension d = scrollPane.getVisibleRect().getSize();
      if (scrollPane.getBorder() != null) {
        d.setSize(
            d.getWidth() - scrollInsets.left - scrollInsets.right,
            d.getHeight() - scrollInsets.top - scrollInsets.bottom);
      }

      if (x <= d.getWidth()) {
        x = ((int) d.getWidth()) - 20;
      }
      if (y <= d.getHeight()) {
        y = ((int) d.getHeight()) - 20;
      }
      desktop.setAllSize(x, y);
      scrollPane.invalidate();
      scrollPane.validate();
    }
  }
コード例 #2
0
 private JScrollPane getScrollPane() {
   if (desktop.getParent() instanceof JViewport) {
     JViewport viewPort = (JViewport) desktop.getParent();
     if (viewPort.getParent() instanceof JScrollPane) {
       return (JScrollPane) viewPort.getParent();
     }
   }
   return null;
 }
コード例 #3
0
  public void setNormalSize() {
    JScrollPane scrollPane = getScrollPane();
    int x = 0;
    int y = 0;
    Insets scrollInsets = getScrollPaneInsets();

    if (scrollPane != null) {
      Dimension d = scrollPane.getVisibleRect().getSize();
      if (scrollPane.getBorder() != null) {
        d.setSize(
            d.getWidth() - scrollInsets.left - scrollInsets.right,
            d.getHeight() - scrollInsets.top - scrollInsets.bottom);
      }

      d.setSize(d.getWidth() - 20, d.getHeight() - 20);
      desktop.setAllSize(x, y);
      scrollPane.invalidate();
      scrollPane.validate();
    }
  }