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


Java Component.getMinimumSize方法代码示例

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


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

示例1: test

import java.awt.Component; //导入方法依赖的package包/类
public void test(final Component component) {
    final Dimension psize = component.getPreferredSize();
    psize.width += 200;
    if (Objects.equals(psize, component.getPreferredSize())) {
        throw new RuntimeException("PreferredSize is wrong");
    }
    final Dimension msize = component.getMaximumSize();
    msize.width += 200;
    if (Objects.equals(msize, component.getMaximumSize())) {
        throw new RuntimeException("MaximumSize is wrong");
    }
    final Dimension misize = component.getMinimumSize();
    misize.width += 200;
    if (Objects.equals(misize, component.getMinimumSize())) {
        throw new RuntimeException("MinimumSize is wrong");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DimensionEncapsulation.java

示例2: minimumLayoutSize

import java.awt.Component; //导入方法依赖的package包/类
public Dimension minimumLayoutSize(Container target) {
    synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int nmembers = target.getComponentCount();
        
        for (int i = 0 ; i < nmembers ; i++) {
            Component m = target.getComponent(i);
            if (m.isVisible()) {
                Dimension d = m.getMinimumSize();
                dim.width = Math.max(dim.width, d.width);
                dim.height += d.height;
            }
        }
        Insets insets = target.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;
        return dim;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:VerticalFlowLayout.java

示例3: minimumLayoutSize

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Dimension minimumLayoutSize(Container container)
{
	Dimension dimension = new Dimension(0, 0);
	for( int i = 0; i < container.getComponentCount(); i++ )
	{
		Component component = container.getComponent(i);
		if( component.isVisible() )
		{
			Dimension dimension1 = component.getMinimumSize();
			dimension.width = Math.max(dimension.width, dimension1.width);
			if( i > 0 )
			{
				dimension.height += vgap;
			}
			dimension.height += dimension1.height;
		}
	}

	Insets insets = container.getInsets();
	dimension.width += insets.left + insets.right + hgap * 2;
	dimension.height += insets.top + insets.bottom + vgap * 2;
	return dimension;
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:VerticalFlowLayout.java

示例4: updateComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * 
 */
public void updateComponent(mxCellState state, Component c)
{
	int x = (int) state.getX();
	int y = (int) state.getY();
	int width = (int) state.getWidth();
	int height = (int) state.getHeight();

	Dimension s = c.getMinimumSize();

	if (s.width > width)
	{
		x -= (s.width - width) / 2;
		width = s.width;
	}

	if (s.height > height)
	{
		y -= (s.height - height) / 2;
		height = s.height;
	}

	c.setBounds(x, y, width, height);
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:27,代码来源:mxGraphComponent.java

示例5: updateComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * 
 */
public void updateComponent(mxCellState state, Component c) {
  int x = (int) state.getX();
  int y = (int) state.getY();
  int width = (int) state.getWidth();
  int height = (int) state.getHeight();

  Dimension s = c.getMinimumSize();

  if (s.width > width) {
    x -= (s.width - width) / 2;
    width = s.width;
  }

  if (s.height > height) {
    y -= (s.height - height) / 2;
    height = s.height;
  }

  c.setBounds(x, y, width, height);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:mxGraphComponent.java

示例6: minimumLayoutSize

import java.awt.Component; //导入方法依赖的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

示例7: evalSize

import java.awt.Component; //导入方法依赖的package包/类
private Dimension evalSize(Container parent, boolean min) {
	synchronized (parent.getTreeLock()) {
		int w = 0, h = 0;
		int nrows = 1, ncols = 1;
		int row = 0, col = 0;
		// eval max size and rows/cols
		for (Component cmp : parent.getComponents())
			if (cmp.isVisible()) {
				ncols = col + 1;
				if (row >= nrows)
					nrows = row + 1;
				// eval size
				Dimension d = min ? cmp.getMinimumSize() : cmp
						.getPreferredSize();
				if (w < d.width)
					w = d.width;
				if (h < d.height)
					h = d.height;
				// eval matrix
				if (++row >= getRows()) {
					row = 0;
					col++;
				}
			}
		// add insets
		Insets insets = parent.getInsets();
		return new Dimension(insets.left + insets.right + ncols * w
				+ (ncols - 1) * getHgap(), insets.top + insets.bottom
				+ nrows * h + (nrows - 1) * getVgap());
	}
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:32,代码来源:MyGridLayout.java

示例8: getMinimumRowHeight

import java.awt.Component; //导入方法依赖的package包/类
private int getMinimumRowHeight(JTable table, int rowIndex) {
    int height = table.getRowHeight();
    
    for (int c=0; c<table.getColumnCount(); c++) {
        TableCellRenderer renderer = table.getCellRenderer(rowIndex, c);
        Component comp = table.prepareRenderer(renderer, rowIndex, c);
        int h = comp.getMinimumSize().height;
        height = Math.max(height, h);
    }
    return height;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:EncapsulateFieldPanel.java

示例9: minimumLayoutSize

import java.awt.Component; //导入方法依赖的package包/类
public Dimension minimumLayoutSize(Container parent) {
    Dimension d = new Dimension( 0,0 );
    d.height = getMinimumHeight();
    for( Component c : getComponents() ) {
        if( !c.isVisible() )
            continue;
        d.width += c.getMinimumSize().width;
    }
    Insets borderInsets = parent.getInsets();
    if( null != borderInsets ) {
        d.height += borderInsets.top;
        d.height += borderInsets.bottom;
    }
    return d;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ToolbarRow.java

示例10: getMinimumHeight

import java.awt.Component; //导入方法依赖的package包/类
private int getMinimumHeight() {
    int h = 0;
    for( Component c : getComponents() ) {
        if( !c.isVisible() )
            continue;
        Dimension d = c.getMinimumSize();
        if( d.height > h )
            h = d.height;
    }
    return h;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ToolbarRow.java

示例11: minimumLayoutSize

import java.awt.Component; //导入方法依赖的package包/类
public Dimension minimumLayoutSize(Container parent) {
    int minw = 0;
    int minh = 0;
    for (Component c : parent.getComponents()) {
        Dimension min = c.getMinimumSize();
        minw += min.width;
        minh = Math.max(minh, min.height);
    }
    minw += HGAP * (parent.getComponentCount() - 1);
    return new Dimension(minw, minh);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SnapshotsWindowUI.java

示例12: getSize

import java.awt.Component; //导入方法依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:CompactLayout.java

示例13: minimumLayoutSize

import java.awt.Component; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Dimension minimumLayoutSize(Container parent) {
    int width = 0;
    int height = 0;
    for (Component comp : parent.getComponents()) {
        Dimension size = comp.getMinimumSize();
        if (size != null) {
            width = Math.max(width, size.width);
            height = Math.max(height, size.height);
        }
    }
    componentDimension = new Dimension(width, height);
    return new Dimension(MAX_COLUMNS * (width + gap) + gap, MAX_ROWS
            * (height + gap) + gap);
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:18,代码来源:CalcLayout.java

示例14: layoutSize

import java.awt.Component; //导入方法依赖的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

示例15: getMinWidth

import java.awt.Component; //导入方法依赖的package包/类
public float getMinWidth (Component widget) {
	return widget.getMinimumSize().width;
}
 
开发者ID:emara-geek,项目名称:object-recognition-tensorflow,代码行数:4,代码来源:SwingToolkit.java


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