javax.swing.JComponent#getMaximumSize ( )源码实例Demo

下面列出了javax.swing.JComponent#getMaximumSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pumpernickel   文件: RowLayout.java
int getMaximumHeight() {
	Row row = rows.get(rowIndex);
	int maxHeight = 0;
	for (int a = 0; a < row.componentListUnwrapped.size(); a++) {
		JComponent jc = row.componentListUnwrapped.get(a);
		if (jc != null && theoreticalBoundsTable.get(jc) != null) {
			int width = theoreticalBoundsTable.get(jc).width;
			Dimension d = getMaximumSize(jc, width);
			if (d == null)
				d = jc.getMaximumSize();
			if (d != null)
				maxHeight = Math.max(maxHeight, d.height);
		}
	}
	return maxHeight;
}
 
源代码2 项目: pumpernickel   文件: RowLayout.java
private int getMaximumExtraHeight(Row row, int[] columnWidths) {
	int maxExtraHeight = 0;
	for (int a = 0; a < row.columns.length; a++) {
		if (row.columns[a] != null) {
			int columnWidth = columnWidths[a];
			for (int b = 0; b < row.columns[a].components.length; b++) {
				JComponent jc = row.columns[a].components[b];
				ComponentConstraints c = row.columns[a].constraints[b];
				if (jc != null
						&& jc.isVisible()
						&& c.verticalPriority == profile.maxVisiblePriority) {
					Dimension maxSize = getMaximumSize(jc, columnWidth);

					if (maxSize == null)
						maxSize = jc.getMaximumSize();
					Dimension preferredSize = getPreferredSize(jc);

					maxExtraHeight = Math.max(maxExtraHeight,
							maxSize.height - preferredSize.height);
				}
			}
		}
	}
	return maxExtraHeight;
}
 
源代码3 项目: netbeans   文件: CompletionLayoutPopup.java
final Dimension getPreferredSize() {
    JComponent comp = getContentComponent();

    if (comp == null)
        return new Dimension(0, 0);
    
    int screenWidth = Utilities.getUsableScreenBounds().width;
    
    Dimension maxSize = new Dimension((int) (screenWidth * MAX_COMPL_COVERAGE),
            comp.getMaximumSize().height); //set maximum part of screen covered
    setMaxSize(comp, maxSize);
    
    return comp.getPreferredSize();
}
 
源代码4 项目: netbeans   文件: CompletionLayoutPopup.java
final Dimension getPreferredSize() {
    JComponent comp = getContentComponent();

    if (comp == null)
        return new Dimension(0, 0);
    
    int screenWidth = Utilities.getUsableScreenBounds().width;
    
    Dimension maxSize = new Dimension((int) (screenWidth * MAX_COMPL_COVERAGE),
            comp.getMaximumSize().height); //set maximum part of screen covered
    setMaxSize(comp, maxSize);
    
    return comp.getPreferredSize();
}
 
源代码5 项目: netbeans   文件: CompletionLayoutPopup.java
final Dimension getPreferredSize() {
    JComponent comp = getContentComponent();

    if (comp == null) {
        return new Dimension(0, 0);
    }

    int screenWidth = Utilities.getUsableScreenBounds().width;

    Dimension maxSize = new Dimension((int) (screenWidth * MAX_COMPL_COVERAGE),
            comp.getMaximumSize().height); //set maximum part of screen covered
    setMaxSize(comp, maxSize);

    return comp.getPreferredSize();
}
 
源代码6 项目: beautyeye   文件: BERootPaneUI.java
/**
 * Returns the maximum amount of space the layout can use.
 *
 * @param target the target
 * @return a Dimension object containing the layout's maximum size
 */ 
public Dimension maximumLayoutSize(Container target)
{
	Dimension cpd, mbd, tpd;
	int cpWidth = Integer.MAX_VALUE;
	int cpHeight = Integer.MAX_VALUE;
	int mbWidth = Integer.MAX_VALUE;
	int mbHeight = Integer.MAX_VALUE;
	int tpWidth = Integer.MAX_VALUE;
	int tpHeight = Integer.MAX_VALUE;
	Insets i = target.getInsets();
	JRootPane root = (JRootPane) target;

	if(root.getContentPane() != null)
	{
		cpd = root.getContentPane().getMaximumSize();
		if (cpd != null) 
		{
			cpWidth = cpd.width;
			cpHeight = cpd.height;
		}
	}

	if(root.getMenuBar() != null) 
	{
		mbd = root.getMenuBar().getMaximumSize();
		if (mbd != null) 
		{
			mbWidth = mbd.width;
			mbHeight = mbd.height;
		}
	}

	if (root.getWindowDecorationStyle() != JRootPane.NONE &&
			(root.getUI() instanceof BERootPaneUI))
	{
		JComponent titlePane = ((BERootPaneUI)root.getUI()).
		getTitlePane();
		if (titlePane != null)
		{
			tpd = titlePane.getMaximumSize();
			if (tpd != null) 
			{
				tpWidth = tpd.width;
				tpHeight = tpd.height;
			}
		}
	}

	int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight);
	// Only overflows if 3 real non-MAX_VALUE heights, sum to > MAX_VALUE
	// Only will happen if sums to more than 2 billion units.  Not likely.
	if (maxHeight != Integer.MAX_VALUE) 
	{
		maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom;
	}

	int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth);
	// Similar overflow comment as above
	if (maxWidth != Integer.MAX_VALUE)
	{
		maxWidth += i.left + i.right;
	}

	return new Dimension(maxWidth, maxHeight);
}
 
源代码7 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * Returns the maximum amount of space the layout can use.
 *
 * @param  target the Container for which this layout manager is being
 *                used
 *
 * @return a Dimension object containing the layout's maximum size
 */
public Dimension maximumLayoutSize(Container target) {
    Dimension cpd;
    Dimension mbd;
    Dimension tpd;
    int       cpWidth  = Integer.MAX_VALUE;
    int       cpHeight = Integer.MAX_VALUE;
    int       mbWidth  = Integer.MAX_VALUE;
    int       mbHeight = Integer.MAX_VALUE;
    int       tpWidth  = Integer.MAX_VALUE;
    int       tpHeight = Integer.MAX_VALUE;
    Insets    i        = target.getInsets();
    JRootPane root     = (JRootPane) target;

    if (root.getContentPane() != null) {
        cpd = root.getContentPane().getMaximumSize();
        if (cpd != null) {
            cpWidth  = cpd.width;
            cpHeight = cpd.height;
        }
    }

    if (root.getJMenuBar() != null) {
        mbd = root.getJMenuBar().getMaximumSize();
        if (mbd != null) {
            mbWidth  = mbd.width;
            mbHeight = mbd.height;
        }
    }

    if (root.getWindowDecorationStyle() != JRootPane.NONE && (root.getUI() instanceof SeaGlassRootPaneUI)) {
        JComponent titlePane = ((SeaGlassRootPaneUI) root.getUI()).getTitlePane();

        if (titlePane != null) {
            tpd = titlePane.getMaximumSize();
            if (tpd != null) {
                tpWidth  = tpd.width;
                tpHeight = tpd.height;
            }
        }
    }

    int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight);
    // Only overflows if 3 real non-MAX_VALUE heights, sum to > MAX_VALUE
    // Only will happen if sums to more than 2 billion units. Not likely.
    if (maxHeight != Integer.MAX_VALUE) {
        maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom;
    }

    int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth);
    // Similar overflow comment as above
    if (maxWidth != Integer.MAX_VALUE) {
        maxWidth += i.left + i.right;
    }

    return new Dimension(maxWidth, maxHeight);
}
 
源代码8 项目: astor   文件: AgeCalculator.java
static JComponent fixedHeight(JComponent component) {
    Dimension dim = component.getMaximumSize();
    dim.height = component.getPreferredSize().height;
    component.setMaximumSize(dim);
    return component;
}
 
源代码9 项目: astor   文件: AgeCalculator.java
static JComponent fixedHeight(JComponent component) {
    Dimension dim = component.getMaximumSize();
    dim.height = component.getPreferredSize().height;
    component.setMaximumSize(dim);
    return component;
}
 
源代码10 项目: usergrid   文件: LauncherFrame.java
public void setMaxWidth( JComponent jc, int width ) {
    Dimension max = jc.getMaximumSize();
    max.width = width;
    jc.setMaximumSize( max );
}
 
源代码11 项目: CQL   文件: JUtils.java
/**
 * Sets the maximum height of a JComponent to its preferred height, thereby
 * preventing it from being expanded. The component itself is returned, to allow
 * shortcuts such as: xyz.add(JUtils.fixHeight(component)).
 *
 * @param c the component to be height-fixed
 * @return the component
 */
public static JComponent fixHeight(JComponent c) {
	Dimension max = c.getMaximumSize();

	max.height = c.getPreferredSize().height;

	c.setMaximumSize(max);

	return c;
}
 
源代码12 项目: CQL   文件: JUtils.java
/**
 * Sets the maximum width of a JComponent to its preferred width, thereby
 * preventing it from being expanded. The component itself is returned, to allow
 * shortcuts such as: xyz.add(JUtils.fixWidth(component)).
 *
 * @param c the component to be width-fixed
 * @return the component
 */
public static JComponent fixWidth(JComponent c) {
	Dimension max = c.getMaximumSize();

	max.width = c.getPreferredSize().width;

	c.setMaximumSize(max);

	return c;
}