当前位置: 首页>>代码示例>>Java>>正文


Java Container.getInsets方法代码示例

本文整理汇总了Java中java.awt.Container.getInsets方法的典型用法代码示例。如果您正苦于以下问题:Java Container.getInsets方法的具体用法?Java Container.getInsets怎么用?Java Container.getInsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Container的用法示例。


在下文中一共展示了Container.getInsets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Lays out the specified container.
 *
 * @param parent the container to be laid out
 * @throws IllegalStateException if any of the components added to
 *         this layout are not in both a horizontal and vertical group
 */
public void layoutContainer(Container parent) {
    // Step 1: Prepare for layout.
    prepare(SPECIFIC_SIZE);
    Insets insets = parent.getInsets();
    int width = parent.getWidth() - insets.left - insets.right;
    int height = parent.getHeight() - insets.top - insets.bottom;
    boolean ltr = isLeftToRight();
    if (getAutoCreateGaps() || getAutoCreateContainerGaps() ||
            hasPreferredPaddingSprings) {
        // Step 2: Calculate autopadding springs
        calculateAutopadding(horizontalGroup, HORIZONTAL, SPECIFIC_SIZE, 0,
                width);
        calculateAutopadding(verticalGroup, VERTICAL, SPECIFIC_SIZE, 0,
                height);
    }
    // Step 3: set the size of the groups.
    horizontalGroup.setSize(HORIZONTAL, 0, width);
    verticalGroup.setSize(VERTICAL, 0, height);
    // Step 4: apply the size to the components.
    for (ComponentInfo info : componentInfos.values()) {
        info.setBounds(insets, width, ltr);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:GroupLayout.java

示例2: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Returns the preferred dimensions given the components in the target
 * container.
 *
 * @param target
 *            the component to lay out
 */
public Dimension preferredLayoutSize(Container target) {
	Dimension tarsiz = new Dimension(0, 0);

	for (int i = 0; i < target.getComponentCount(); i++) {
		Component m = target.getComponent(i);
		if (m.isVisible()) {
			Dimension d = m.getPreferredSize();
			tarsiz.width = Math.max(tarsiz.width, d.width);
			if (i > 0) {
				tarsiz.height += hgap;
			}
			tarsiz.height += d.height;
		}
	}
	Insets insets = target.getInsets();
	tarsiz.width += insets.left + insets.right + hgap * 2;
	tarsiz.height += insets.top + insets.bottom + vgap * 2;
	return tarsiz;
}
 
开发者ID:Harlber,项目名称:Method_Trace_Tool,代码行数:27,代码来源:VerticalFlowLayout.java

示例3: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
@Override
public void layoutContainer(Container parent) {
	Insets in = parent.getInsets();
	int maxWidth = parent.getWidth() - (in.left + in.right);
	int maxHeight = parent.getHeight() - (in.top + in.bottom);
	int split;
	if (fraction <= 0.0) {
		split = 0;
	} else if (fraction >= 1.0) {
		split = maxWidth;
	} else {
		split = (int) Math.round(maxWidth * fraction);
		split = Math.min(split, maxWidth - comp1.getMinimumSize().width);
		split = Math.max(split, comp0.getMinimumSize().width);
	}

	comp0.setBounds(in.left, in.top, split, maxHeight);
	comp1.setBounds(in.left + split, in.top, maxWidth - split, maxHeight);
	dragbar.setBounds(in.left + split - HorizontalSplitPane.DRAG_TOLERANCE, in.top,
			2 * HorizontalSplitPane.DRAG_TOLERANCE, maxHeight);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:VerticalSplitPane.java

示例4: minimumLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Returns the minimum size needed to layout the target container.
 *
 * @param target
 *            the component to lay out.
 * @return the minimum layout dimension.
 */
public Dimension minimumLayoutSize(Container target) {
	Dimension tarsiz = new Dimension(0, 0);

	for (int i = 0; i < target.getComponentCount(); i++) {
		Component m = target.getComponent(i);
		if (m.isVisible()) {
			Dimension d = m.getMinimumSize();
			tarsiz.width = Math.max(tarsiz.width, d.width);
			if (i > 0) {
				tarsiz.height += vgap;
			}
			tarsiz.height += d.height;
		}
	}
	Insets insets = target.getInsets();
	tarsiz.width += insets.left + insets.right + hgap * 2;
	tarsiz.height += insets.top + insets.bottom + vgap * 2;
	return tarsiz;
}
 
开发者ID:Harlber,项目名称:Method_Trace_Tool,代码行数:27,代码来源:VerticalFlowLayout.java

示例5: minimumLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension minimumLayoutSize(final Container parent) {
    final Insets insets = parent.getInsets();
    final Dimension d = new Dimension(insets.left + insets.right,
                                      insets.top + insets.bottom);
    int maxWidth = 0;
    int visibleCount = 0;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible() && !(comp instanceof Box.Filler)) {
            final Dimension size = comp.getPreferredSize();
            maxWidth = Math.max(maxWidth, size.width);
            d.height += size.height;
            visibleCount++;
        }
    }

    d.height += (visibleCount - 1) * vGap;
    d.width += maxWidth;

    return d;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:VerticalLayout.java

示例6: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension preferredLayoutSize(Container parent) {
    int prefw = 0;
    int prefh = 0;
    for (Component c : parent.getComponents()) {
        Dimension pref = c.getPreferredSize();
        prefw += pref.width;
        prefh = Math.max(prefh, pref.height);
    }
    prefw += HGAP * (parent.getComponentCount() - 1);
    
    Insets i = parent.getInsets();
    prefw += i.left + i.right;
    prefh += i.top + i.bottom;
    
    return new Dimension(prefw, prefh);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SnapshotsWindowUI.java

示例7: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
@Override
public Dimension preferredLayoutSize(Container container) 
{
	Insets insets = container.getInsets();
	int longestRow = max( getRowWidths() ) + insets.left + insets.right;
	int sumRowHeights = sum( getRowHeights()  ) + insets.top + insets.bottom;
	return new Dimension(longestRow, sumRowHeights);
}
 
开发者ID:jpxor,项目名称:slick,代码行数:9,代码来源:SlickLayout.java

示例8: computeDimension

import java.awt.Container; //导入方法依赖的package包/类
private Dimension computeDimension(Container parent, int type) {
    Insets insets = parent.getInsets();
    int x = insets.left;
    int y = insets.top;
    int columnWidth = 0;
    // int limitHeight = parent.getHeight() - insets.bottom;
    int maxY = 0;

    for (Component c : this.components) {
        if (c.isVisible()) {
            Dimension d;

            switch (type) {
                case 0:
                    d = c.getPreferredSize();
                    break;
                case 1:
                    d = c.getMinimumSize();
                    break;
                default:
                    d = c.getMaximumSize();
                    break;
            }
            columnWidth = Math.max(columnWidth, d.width);
            /*
            if (limitHeight != 0 && y + d.height >= limitHeight) {
                x += columnWidth + this.hgap;
                y = insets.top;
                columnWidth = d.width;
            }
            */
            y += d.height;
            maxY = Math.max(y, maxY);
            y += this.vgap;
        }
    }
    x += columnWidth;
    return new Dimension(x, maxY);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:VerticalFlowLayout.java

示例9: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension preferredLayoutSize(Container container) {
    Dimension tabSize = tabDisplayer.getPreferredSize();
    Dimension contentSize = contentDisplayer.getPreferredSize();
    Insets ins = container.getInsets();
    Dimension result = new Dimension(ins.left + ins.top, ins.right + ins.bottom);
    result.width += Math.max (tabSize.width, contentSize.width);
    result.height += tabSize.height + contentSize.height;
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:DefaultTabbedContainerUI.java

示例10: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Lays out the specified container.
 * @param parent the container to be laid out
 */
public void layoutContainer(Container parent) {
    int n = parent.getComponentCount();
    Insets insets = parent.getInsets();
    Dimension size = parent.getSize();
    int c = horizontal ? insets.left : insets.top;
    int x, y;
    int ebx = size.width - insets.right;
    size.width -= (insets.left + insets.right);
    size.height -= (insets.top + insets.bottom);
    for (int i = 0; i < n; i++) {
        Component comp = parent.getComponent(i);
        Dimension pref = comp.getPreferredSize();
        if (comp instanceof EnableButton) {
            ebx -= 4;
            ebx -= pref.width;
            x = ebx;
            y = (insets.top - pref.height) / 2;
        } else if (horizontal) {
            x = c;
            c += pref.width;
            y = insets.top;
            pref.height = size.height;
        } else {
            x = insets.left;
            pref.width = size.width;
            y = c;
            c += pref.height;
        }
        comp.setBounds(x, y, pref.width, pref.height);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:CompactLayout.java

示例11: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    int maxWidth = parent.getWidth() - (insets.left + insets.right);
    int maxHeight = parent.getHeight() - (insets.top + insets.bottom);
    int width = 0;
    int height = 0;

    width = ((maxWidth - gap * (MAX_COLUMNS + 1)) / MAX_COLUMNS);
    height = ((maxHeight - gap * (MAX_ROWS + 1)) / MAX_ROWS);
    componentDimension = new Dimension(width, height);

    for (Component comp : parent.getComponents()) {
        RCPosition position = components.get(comp);
        int row = position.getRow();
        int column = position.getColumn();
        if (position != null) {
            int x = insets.left + column * gap + (column - 1)
                    * componentDimension.width;
            int y = insets.top + row * gap + (row - 1)
                    * componentDimension.height;
            if (row == 1 && column == 1) {
                comp.setBounds(x, y,
                        componentDimension.width * 5 + 4 * gap,
                        componentDimension.height);
            } else {
                comp.setBounds(x, y, componentDimension.width,
                        componentDimension.height);
            }
        }
    }
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:35,代码来源:CalcLayout.java

示例12: getSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension getSize(Container parent, boolean minimum) {
    int n = parent.getComponentCount();
    Insets insets = parent.getInsets();
    Dimension d = new Dimension();
    for (int i = 0; i < n; i++) {
        Component comp = parent.getComponent(i);
        if (comp instanceof EnableButton) {
            continue;
        }
        Dimension p = (minimum
                       ? comp.getMinimumSize()
                       : comp.getPreferredSize());
        if (horizontal) {
            d.width += p.width;
            if (d.height < p.height) {
                d.height = p.height;
            }
        } else {
            if (d.width < p.width) {
                d.width = p.width;
            }
            d.height += p.height;
        }
    }
    d.width += (insets.left + insets.right);
    d.height += (insets.top + insets.bottom);
    return d;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:CompactLayout.java

示例13: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
@Override
public Dimension preferredLayoutSize(Container parent) {
	Component label = getLabel(parent);
	Dimension labelSize = label.getPreferredSize();
	Insets insets = parent.getInsets();
	int width = labelSize.width + insets.left + insets.right;
	int height = labelSize.height + insets.top + insets.bottom;
	return new Dimension(width, height);
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:10,代码来源:TitledSeperatorLayout.java

示例14: getInsets

import java.awt.Container; //导入方法依赖的package包/类
/**
 * 
 * @param target
 * @return insets
 */
protected Insets getInsets(Container target) {
	Insets insets = target.getInsets();
	totalInsets.top = insets.top + extraInsets.top;
	totalInsets.left = insets.left + extraInsets.left;
	totalInsets.bottom = insets.bottom + extraInsets.bottom;
	totalInsets.right = insets.right + extraInsets.right;
	return totalInsets;
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:14,代码来源:RiverLayout.java

示例15: layoutSize

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Returns the minimum or preferred dimension needed to layout the target
 * container.
 *
 * @param target target to get layout size for
 * @param preferred should preferred size be calculated
 * @return the dimension to layout the target container
 */
private Dimension layoutSize(final Container target, final boolean preferred) {
	synchronized (target.getTreeLock()) {
		//  Each row must fit with the width allocated to the containter.
		//  When the container width = 0, the preferred width of the container
		//  has not yet been calculated so lets ask for the maximum.

		int targetWidth = target.getSize().width;

		if (targetWidth == 0) {
			targetWidth = Integer.MAX_VALUE;
		}

		final int hgap = getHgap();
		final int vgap = getVgap();
		final Insets insets = target.getInsets();
		final int horizontalInsetsAndGap = insets.left + insets.right + (hgap * 2);
		final int maxWidth = targetWidth - horizontalInsetsAndGap;

		//  Fit components into the allowed width

		final Dimension dim = new Dimension(0, 0);
		int rowWidth = 0;
		int rowHeight = 0;

		final int nmembers = target.getComponentCount();

		for (int i = 0; i < nmembers; i++) {
			final Component m = target.getComponent(i);

			if (m.isVisible()) {
				final Dimension d = preferred ? m.getPreferredSize() : m.getMinimumSize();

				//  Can't add the component to current row. Start a new row.

				if (rowWidth + d.width > maxWidth) {
					addRow(dim, rowWidth, rowHeight);
					rowWidth = 0;
					rowHeight = 0;
				}

				//  Add a horizontal gap for all components after the first

				if (rowWidth != 0) {
					rowWidth += hgap;
				}

				rowWidth += d.width;
				rowHeight = Math.max(rowHeight, d.height);
			}
		}

		addRow(dim, rowWidth, rowHeight);

		dim.width += horizontalInsetsAndGap;
		dim.height += insets.top + insets.bottom + vgap * 2;

		//	When using a scroll pane or the DecoratedLookAndFeel we need to
		//  make sure the preferred size is less than the size of the
		//  target containter so shrinking the container size works
		//  correctly. Removing the horizontal gap is an easy way to do this.

		final Container scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane.class, target);

		if (scrollPane != null && target.isValid()) {
			dim.width -= (hgap + 1);
		}

		return dim;
	}
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:79,代码来源:WrapLayout.java


注:本文中的java.awt.Container.getInsets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。