本文整理了Java中java.awt.Container.getSize()
方法的一些代码示例,展示了Container.getSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container.getSize()
方法的具体详情如下:
包路径:java.awt.Container
类名称:Container
方法名:getSize
暂无
代码示例来源:origin: JetBrains/ideavim
@NotNull
private Dimension calcSize(@NotNull Dimension dimension) {
final Container container = getParent();
if (container != null) {
final Dimension size = container.getSize();
return new Dimension(size.width, dimension.height);
}
return dimension;
}
代码示例来源:origin: org.codehaus.groovy/groovy
@Override
public void setSize(final Dimension d) {
if (d.width < getParent().getSize().width) {
d.width = getParent().getSize().width;
}
super.setSize(d);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
@Override
public boolean getScrollableTracksViewportWidth() {
return (getSize().width < getParent().getSize().width);
}
代码示例来源: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: nodebox/nodebox
@Override
public Dimension preferredLayoutSize(Container container) {
return container.getSize();
}
代码示例来源:origin: nodebox/nodebox
@Override
public Dimension minimumLayoutSize(Container container) {
return container.getSize();
}
代码示例来源:origin: apache/geode
void resizeMe(int zoomBoxX, int zoomBoxY, int zoomBoxWidth, int zoomBoxHeight) {
Dimension viewSize = getParent().getSize();
double windowWidth = viewSize.getWidth();
double windowHeight = viewSize.getHeight();
double scaleX = getWidth() / ((double) zoomBoxWidth);
double scaleY = getHeight() / ((double) zoomBoxHeight);
int oldWidth = getWidth();
int oldHeight = getHeight();
int width = (int) (scaleX * windowWidth);
int height = (int) (scaleY * windowHeight);
// this.setPreferredSize(new Dimension(width, height));
child.resizeMe(width, height);
// TODO not sure this one is needed
this.revalidate();
// scroll to the new rectangle
// int scrollX = (int) (zoomBoxX * scaleX);
// int scrollY = (int) (zoomBoxY * scaleY);
// int scrollWidth= (int) (zoomBoxWidth * scaleX);
// int scrollHeight = (int) (zoomBoxHeight * scaleY);
int scrollX = (int) (zoomBoxX * (width / (double) oldWidth));
int scrollY = (int) (zoomBoxY * (height / (double) oldHeight));
int scrollWidth = (int) (zoomBoxWidth * (width / (double) oldWidth));
int scrollHeight = (int) (zoomBoxHeight * (height / (double) oldHeight));
Rectangle r = new Rectangle(scrollX, scrollY, scrollWidth, scrollHeight);
((JViewport) getParent()).scrollRectToVisible(r);
repaint();
}
代码示例来源:origin: tomighty/tomighty
private void fill(Component child, Container parent) {
child.setLocation(0, 0);
child.setSize(parent.getSize());
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
/**
* The preferredSize of a list is total height of the rows
* and the maximum width of the cells. If JList.fixedCellHeight
* is specified then the total height of the rows is just
* (cellVerticalMargins + fixedCellHeight) * model.getSize() where
* rowVerticalMargins is the space we allocate for drawing
* the yellow focus outline. Similarly if JListfixedCellWidth is
* specified then we just use that plus the horizontal margins.
*
* @return The total size of the
*/
public Dimension getPreferredSize() {
Insets insets = getInsets();
/*
int dx = insets.left + insets.right;
int dy = insets.top + insets.bottom;
*/
int max = getModel().getSize() - 1;
if (max <= 0) {
return new Dimension(fixedCellWidth, fixedCellHeight);
}
int y = (max / realColumnCount) + 1;
int x = ((max < realColumnCount) ? (max + 1) : realColumnCount);
int xParent = getParent().getSize().width;
int yParent = getParent().getSize().height;
int xRes = Math.max(xParent, x * fixedCellWidth);
int yRes = Math.max(yParent, y * fixedCellHeight);
Dimension d = new Dimension(xRes, yRes);
return d;
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
public void layoutContainer(Container parent) {
Dimension d = parent.getSize();
int sPosition = splitPosition;
代码示例来源:origin: ron190/jsql-injection
@Override
public boolean getScrollableTracksViewportWidth() {
return this.getUI().getPreferredSize(this).width <= this.getParent().getSize().width;
}
代码示例来源:origin: magefree/mage
int spaceAvailable = parent.getSize().height
- insets.top
- insets.bottom
int y = insets.top + borderGap;
int insetGap = insets.left + insets.right;
int parentWidth = parent.getSize().width - insetGap;
代码示例来源:origin: magefree/mage
int spaceAvailable = parent.getSize().width
- insets.left
- insets.right
int y = insets.top;
int insetGap = insets.top + insets.bottom;
int parentHeight = parent.getSize().height - insetGap;
代码示例来源:origin: org.netbeans.api/org-openide-awt
int maxwidth = target.getSize().width - (insets.left + insets.right + (getHgap() * 2));
int nmembers = target.getComponentCount();
int x = 0;
代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-runtime
private Dimension getBoundingSize(Component source) {
if (source instanceof Window) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle bounds = env.getMaximumWindowBounds();
return new Dimension(bounds.width, bounds.height);
} else {
return source.getParent().getSize();
}
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime
private Dimension getBoundingSize(Component source) {
if (source instanceof Window) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle bounds = env.getMaximumWindowBounds();
return new Dimension(bounds.width, bounds.height);
} else {
return source.getParent().getSize();
}
}
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime
private Dimension getBoundingSize(Component source) {
if (source instanceof Window) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle bounds = env.getMaximumWindowBounds();
return new Dimension(bounds.width, bounds.height);
} else {
return source.getParent().getSize();
}
}
代码示例来源:origin: jitsi/libjitsi
protected void layoutContainer(Container parent, float componentAlignmentX)
{
Component component = getComponent(parent);
if (component != null)
{
layoutComponent(
component,
new Rectangle(parent.getSize()),
componentAlignmentX, Component.CENTER_ALIGNMENT);
}
}
代码示例来源:origin: freeplane/freeplane
public Dimension preferredLayoutSize(final Container c) {
if (!c.isValid()) {
c.validate();
}
return c.getSize();
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
public Dimension getPreferredScrollableViewportSize() {
Dimension pref = super.getPreferredScrollableViewportSize();
if ((this.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF) && (getParent() != null)) {
Insets insets = getParent().getInsets();
Dimension size = getParent().getSize();
pref.height = size.height - insets.top - insets.bottom;
}
return pref;
}
内容来源于网络,如有侵权,请联系作者删除!