java.awt.Container.getBounds()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中java.awt.Container.getBounds()方法的一些代码示例,展示了Container.getBounds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container.getBounds()方法的具体详情如下:
包路径:java.awt.Container
类名称:Container
方法名:getBounds

Container.getBounds介绍

暂无

代码示例

代码示例来源:origin: JetBrains/ideavim

private void positionPanel() {
 if (parent == null) return;
 Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, parent);
 int height = (int)getPreferredSize().getHeight();
 if (scroll != null) {
  Rectangle bounds = scroll.getBounds();
  bounds.translate(0, scroll.getHeight() - height);
  bounds.height = height;
  Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), oldGlass);
  bounds.setLocation(pos);
  setBounds(bounds);
  repaint();
 }
}

代码示例来源:origin: JetBrains/ideavim

final int height = (int)getPreferredSize().getHeight();
if (scroll != null) {
 final Rectangle bounds = scroll.getBounds();
 bounds.translate(0, scroll.getHeight() - height);
 bounds.height = height;

代码示例来源:origin: JetBrains/ideavim

private void positionPanel() {
 final JComponent contentComponent = myEditor.getContentComponent();
 Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, contentComponent);
 setSize(scroll.getSize());
 myLineHeight = myText.getFontMetrics(myText.getFont()).getHeight();
 int count = countLines(myText.getText());
 int visLines = getSize().height / myLineHeight - 1;
 int lines = Math.min(count, visLines);
 setSize(getSize().width, lines * myLineHeight + myLabel.getPreferredSize().height +
              getBorder().getBorderInsets(this).top * 2);
 int height = getSize().height;
 Rectangle bounds = scroll.getBounds();
 bounds.translate(0, scroll.getHeight() - height);
 bounds.height = height;
 Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(),
                     SwingUtilities.getRootPane(contentComponent).getGlassPane());
 bounds.setLocation(pos);
 setBounds(bounds);
 myScrollPane.getVerticalScrollBar().setValue(0);
 if (!Options.getInstance().isSet("more")) {
  // FIX
  scrollOffset(100000);
 }
 else {
  scrollOffset(0);
 }
}

代码示例来源:origin: brackeen/Scared

@Override
  public void componentResized(ComponentEvent e) {
    setBounds(contentPane.getBounds());
  }
});

代码示例来源:origin: stackoverflow.com

Container parent = titleLabel.getParent();
parent.scrollRectToVisible(parent.getBounds());

代码示例来源:origin: freeplane/freeplane

@Override
public Insets getAutoscrollInsets() {
  final Container parent = getParent();
  if (parent == null) {
    return new Insets(0, 0, 0, 0);
  }
  final Rectangle outer = getBounds();
  final Rectangle inner = parent.getBounds();
  return new Insets(inner.y - outer.y + MapView.margin, inner.x - outer.x + MapView.margin, outer.height
      - inner.height - inner.y + outer.y + MapView.margin, outer.width - inner.width - inner.x + outer.x
      + MapView.margin);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private int getPopupFitHeight(Rectangle popupRectInScreen, Component invoker) {
  if (invoker != null) {
    Container parent;
    for (parent = invoker.getParent(); parent != null; parent = parent.getParent()) {
      if (parent instanceof JFrame || parent instanceof JDialog || parent instanceof JWindow) {
        return getHeightAdjust(parent.getBounds(), popupRectInScreen);
      } else if (parent instanceof JApplet || parent instanceof JInternalFrame) {
        if (popupFrameRect == null) {
          popupFrameRect = new Rectangle();
        }
        Point p = parent.getLocationOnScreen();
        popupFrameRect.setBounds(p.x, p.y, parent.getBounds().width, parent.getBounds().height);
        return getHeightAdjust(popupFrameRect, popupRectInScreen);
      }
    }
  }
  return 0;
}

代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun

private int getPopupFitHeight(Rectangle popupRectInScreen, Component invoker) {
  if (invoker != null) {
    Container parent;
    for (parent = invoker.getParent(); parent != null; parent = parent.getParent()) {
      if (parent instanceof JFrame || parent instanceof JDialog || parent instanceof JWindow) {
        return getHeightAdjust(parent.getBounds(), popupRectInScreen);
      } else if (parent instanceof JApplet || parent instanceof JInternalFrame) {
        if (popupFrameRect == null) {
          popupFrameRect = new Rectangle();
        }
        Point p = parent.getLocationOnScreen();
        popupFrameRect.setBounds(p.x, p.y, parent.getBounds().width, parent.getBounds().height);
        return getHeightAdjust(popupFrameRect, popupRectInScreen);
      }
    }
  }
  return 0;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private int getPopupFitWidth(Rectangle popupRectInScreen, Component invoker) {
  if (invoker != null) {
    Container parent;
    for (parent = invoker.getParent(); parent != null; parent = parent.getParent()) {
      if (parent instanceof JFrame || parent instanceof JDialog || parent instanceof JWindow) {
        return getWidthAdjust(parent.getBounds(), popupRectInScreen);
      } else if (parent instanceof JApplet || parent instanceof JInternalFrame) {
        if (popupFrameRect == null) {
          popupFrameRect = new Rectangle();
        }
        Point p = parent.getLocationOnScreen();
        popupFrameRect.setBounds(p.x, p.y, parent.getBounds().width, parent.getBounds().height);
        return getWidthAdjust(popupFrameRect, popupRectInScreen);
      }
    }
  }
  return 0;
}

代码示例来源:origin: antlr/antlrworks

public Insets getAutoscrollInsets() {
  Rectangle outer = getBounds();
  Rectangle inner = getParent().getBounds();
  return new Insets(inner.y-outer.y+margin, inner.x-outer.x+margin,
      outer.height-inner.height+margin,
      outer.width-inner.width+margin);
}

代码示例来源:origin: antlr/antlrworks

public Insets getAutoscrollInsets() {
  Rectangle outer = getBounds();
  Rectangle inner = getParent().getBounds();
  return new Insets(inner.y-outer.y+AUTOSCROLL_MARGIN, inner.x-outer.x+AUTOSCROLL_MARGIN,
      outer.height-inner.height+AUTOSCROLL_MARGIN,
      outer.width-inner.width+AUTOSCROLL_MARGIN);
}

代码示例来源:origin: uk.org.mygrid.taverna.scufl.scufl-ui-components/iteration-strategy-editor

public Insets getAutoscrollInsets() {
  Rectangle raOuter = getBounds();
  Rectangle raInner = getParent().getBounds();
  return new Insets(raInner.y - raOuter.y + AUTOSCROLL_MARGIN, raInner.x - raOuter.x + AUTOSCROLL_MARGIN,
      raOuter.height - raInner.height - raInner.y + raOuter.y + AUTOSCROLL_MARGIN, raOuter.width
          - raInner.width - raInner.x + raOuter.x + AUTOSCROLL_MARGIN);
}

代码示例来源:origin: info.aduna.clustermap/aduna-clustermap-core

public void layoutContainer(Container parent) {
  Rectangle b = parent.getBounds();
  b.x = 0;
  b.y = 0;
  scrollPane.setBounds(b);
  toolTipPanel.setBounds(b);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-dlight-core-ui

public void layoutContainer(Container parent) {
  Rectangle b = parent.getBounds();
  int inset = 8;
  int vOffset = 20;
  int hOffset = 0;
  int btnWSize = 80;

  if (parent.getComponentCount() > 1) {
   JButton btn = (JButton) parent.getComponent(BTN_IDX);
   int btnHSize = (int) btn.getPreferredSize().getHeight();
   btn.setBounds(b.width - inset - btnWSize, vOffset, btnWSize, btnHSize);
   hOffset = inset + btnWSize;
  }

  JComboBox combo = (JComboBox) parent.getComponent(COMBO_IDX);
  int comboHSize = (int) combo.getPreferredSize().getHeight() + 1;
  combo.setBounds(inset, vOffset, b.width - 2 * inset - hOffset, comboHSize);

 }
}

代码示例来源:origin: joel-costigliola/assertj-swing

@RunsInCurrentThread
static @Nonnull Pair<Point, Container> pointAndParentForScrolling(final @Nonnull JTextField textField) {
 Point origin = new Point(textField.getX(), textField.getY());
 Container parent = textField.getParent();
 while (parent != null && !(parent instanceof JComponent) && !(parent instanceof CellRendererPane)) {
  origin = addRectangleToPoint(checkNotNull(parent.getBounds()), origin);
  parent = parent.getParent();
 }
 return Pair.of(origin, parent);
}

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

public Dimension preferredLayoutSize(Container parent) {
  Dimension size = preferredNodeSize(getModel(), parent.getBounds());
  return sizeWithInsets(parent, size);
}

代码示例来源:origin: jpcsp/jpcsp

@Override
public Rectangle getCaptureRectangle() {
  Insets insets = getInsets();
  Rectangle canvasBounds = Modules.sceDisplayModule.getCanvas().getBounds();
  Rectangle contentBounds = getContentPane().getBounds();
  return new Rectangle(getX() + insets.left + contentBounds.x + canvasBounds.x, getY() + insets.top + contentBounds.y + canvasBounds.y, canvasBounds.width, canvasBounds.height);
}

代码示例来源:origin: mucommander/mucommander

@Override
  public void repaint() {
    Container parent = getParent();
    if (parent != null) {
      Rectangle parentBounds = parent.getBounds();
      int parentWidth = parentBounds.width;

      if (lastParentWidth != parentWidth) {
        lastParentWidth = parentWidth;

        int itemsPerRow = parentWidth / itemWidth;
        setFixedCellWidth(itemWidth + ((parentWidth - itemWidth * itemsPerRow)/ itemsPerRow));
        setVisibleRowCount(getComponentCount() / itemsPerRow);
      }
    }
    
    super.repaint();
  }
}

代码示例来源:origin: com.github.insubstantial/flamingo

@Override
public void layoutContainer(Container parent) {
  currLM.layoutContainer(parent);
  JRibbonFrame ribbonFrame = JRibbonFrame.this;
  if (ribbonFrame.getRootPane().getWindowDecorationStyle() != JRootPane.NONE)
    keyTipLayer
        .setBounds(ribbonFrame.getRootPane().getBounds());
  else
    keyTipLayer.setBounds(ribbonFrame.getRootPane()
        .getContentPane().getBounds());
}

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

public void propertyChange(PropertyChangeEvent evt) {
    if (toolWindow.getType() == ToolWindowType.FLOATING_LIVE) {
      if ((Boolean) evt.getNewValue()) {
        oldBounds = sheet.getBounds();
        Rectangle bounds = descriptor.getManager().getMainContainer().getBounds();
        bounds = SwingUtilities.convertRectangle(descriptor.getManager().getMainContainer(),
            bounds,
            descriptor.getManager().getRootPane().getLayeredPane());
        sheet.setBounds(bounds);
      } else {
        sheet.setBounds(oldBounds);
      }
      SwingUtil.repaint(sheet);
    }
  }
});

相关文章

微信公众号

最新文章

更多

Container类方法