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


Java Container.getTreeLock方法代码示例

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


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

示例1: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension preferredLayoutSize(Container parent) {
    synchronized (parent.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        Dimension cen = center != null ? center.getPreferredSize() : null;

        if (north != null) dim.height += north.getPreferredSize().height;
        if (cen   != null) dim.height += cen.height;
        if (south != null) dim.height += south.getPreferredSize().height;

        if (west != null) dim.width += west.getPreferredSize().width;
        if (cen  != null) dim.width += cen.width;
        if (east != null) dim.width += east.getPreferredSize().width;

        Insets insets = parent.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;

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

示例2: minimumLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension minimumLayoutSize(Container parent) {
    synchronized (parent.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        Dimension cen = center != null ? center.getMinimumSize() : null;

        if (north != null) dim.height += north.getMinimumSize().height;
        if (cen   != null) dim.height += cen.height;
        if (south != null) dim.height += south.getMinimumSize().height;

        if (west != null) dim.width += west.getMinimumSize().width;
        if (cen   != null) dim.width += cen.width;
        if (east != null) dim.width += east.getMinimumSize().width;

        Insets insets = parent.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;

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

示例3: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
public Dimension preferredLayoutSize(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.getPreferredSize();
                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

示例4: minimumLayoutSize

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

示例5: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
public void layoutContainer(Container target) {
    
    synchronized (target.getTreeLock()) {
        Insets insets = target.getInsets();
        int maxwidth = parent.getWidth() - (insets.left + insets.right);
        int nmembers = target.getComponentCount();
        int x = insets.left, y = insets.top;
        
        for (int i = 0 ; i < nmembers ; i++) {
            Component m = target.getComponent(i);
            if (m.isVisible()) {
                Dimension d = m.getPreferredSize();
                m.setSize(maxwidth, d.height);
                m.setLocation(x, y);
                y += d.height;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:VerticalFlowLayout.java

示例6: preferredLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param target Description of Parameter
 * @return Description of the Returned Value
 */
public Dimension preferredLayoutSize(Container target) {
    synchronized (target.getTreeLock()) {
        Dimension dim = new Dimension(0, 0);
        int nmembers = target.getComponentCount();
        boolean firstVisibleComponent = true;

        for (int ii = 0; ii < nmembers; ii++) {
            Component m = target.getComponent(ii);
            if (m.isVisible()) {
                Dimension d = m.getPreferredSize();
                dim.width = Math.max(dim.width, d.width);
                if (firstVisibleComponent) {
                    firstVisibleComponent = false;
                } else {
                    dim.height += _vgap;
                }
                dim.height += d.height;
            }
        }
        Insets insets = target.getInsets();
        dim.width += insets.left + insets.right;//+ _hgap * 2;
        dim.height += insets.top + insets.bottom;// + _vgap * 2;
        return dim;
    }
}
 
开发者ID:TheCaveCz,项目名称:letsmake-ledmatrix,代码行数:32,代码来源:VerticalFlowLayout.java

示例7: evalSize

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

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param target
 *            Description of Parameter
 * @return Description of the Returned Value
 */
@Override
public Dimension preferredLayoutSize(Container target){
	synchronized(target.getTreeLock()){
		Dimension dim=new Dimension(0, 0);
		int nmembers=target.getComponentCount();
		boolean firstVisibleComponent=true;
		
		for(int ii=0;ii<nmembers;ii++){
			Component m=target.getComponent(ii);
			if(m.isVisible()){
				Dimension d=m.getPreferredSize();
				dim.width=Math.max(dim.width, d.width);
				if(firstVisibleComponent){
					firstVisibleComponent=false;
				}else{
					dim.height+=_vgap;
				}
				dim.height+=d.height;
			}
		}
		Insets insets=target.getInsets();
		dim.width+=insets.left+insets.right+_hgap*2;
		dim.height+=insets.top+insets.bottom+_vgap*2;
		return dim;
	}
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:34,代码来源:VerticalFlowLayout.java

示例9: minimumLayoutSize

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param target
 *            Description of Parameter
 * @return Description of the Returned Value
 */
@Override
public Dimension minimumLayoutSize(Container target){
	synchronized(target.getTreeLock()){
		Dimension dim=new Dimension(0, 0);
		int nmembers=target.getComponentCount();
		boolean firstVisibleComponent=true;
		
		for(int ii=0;ii<nmembers;ii++){
			Component m=target.getComponent(ii);
			if(m.isVisible()){
				Dimension d=m.getPreferredSize();
				dim.width=Math.max(dim.width, d.width);
				if(firstVisibleComponent){
					firstVisibleComponent=false;
				}else{
					dim.height+=_vgap;
				}
				dim.height+=d.height;
			}
		}
		Insets insets=target.getInsets();
		dim.width+=insets.left+insets.right+_hgap*2;
		dim.height+=insets.top+insets.bottom+_vgap*2;
		return dim;
	}
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:34,代码来源:VerticalFlowLayout.java

示例10: invalidateLayout

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Invalidates the layout, indicating that if the layout manager
 * has cached information it should be discarded.
 *
 * @param parent Container hosting this LayoutManager
 * @throws IllegalArgumentException if <code>parent</code> is not
 *         the same <code>Container</code> that this was created with
 */
public void invalidateLayout(Container parent) {
    checkParent(parent);
    // invalidateLayout is called from Container.invalidate, which
    // does NOT grab the treelock.  All other methods do.  To make sure
    // there aren't any possible threading problems we grab the tree lock
    // here.
    synchronized(parent.getTreeLock()) {
        isValid = false;
    }
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:19,代码来源:GroupLayout.java

示例11: moveComponents

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Centers the elements in the specified row, if there is any slack.
 * @param target the component which needs to be moved
 * @param x the x coordinate
 * @param y the y coordinate
 * @param width the width dimensions
 * @param height the height dimensions
 * @param rowStart the beginning of the row
 * @param rowEnd the the ending of the row
 * @param ltr 
 * @param ruler 
 */
protected void moveComponents(Container target, int x, int y, int width,
		int height, int rowStart, int rowEnd, boolean ltr, Ruler ruler) {
	synchronized (target.getTreeLock()) {
		switch (getAlignment()) {
		case FlowLayout.LEFT:
			x += ltr ? 0 : width;
			break;
		case FlowLayout.CENTER:
			x += width / 2;
			break;
		case FlowLayout.RIGHT:
			x += ltr ? width : 0;
			break;
		case LEADING:
			break;
		case TRAILING:
			x += width;
			break;
		}
		int tabIndex = 0;
		for (int i = rowStart; i < rowEnd; i++) {
			Component m = target.getComponent(i);
			//          if (m.isVisible()) {
			if (hasConstraint(m, TAB_STOP))
				x = getInsets(target).left + ruler.getTab(tabIndex++);
			int dy = (valign == VTOP) ? 0 : (height - m.getHeight()) / 2;
			if (ltr) {
				m.setLocation(x, y + dy);
			} else {
				m.setLocation(target.getWidth() - x - m.getWidth(), y + dy);
			}
			x += m.getWidth() + hgap;
			//            }
		}
	}
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:49,代码来源:RiverLayout.java

示例12: relMove

import java.awt.Container; //导入方法依赖的package包/类
protected void relMove(Container target, int dx, int dy, int rowStart,
		int rowEnd) {
	synchronized (target.getTreeLock()) {
		for (int i = rowStart; i < rowEnd; i++) {
			Component m = target.getComponent(i);
			//            if (m.isVisible()) {
			m.setLocation(m.getX() + dx, m.getY() + dy);
			//            }
		}

	}
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:13,代码来源:RiverLayout.java

示例13: invalidateLayout

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Invalidates the layout, indicating that if the layout manager
 * has cached information it should be discarded.
 *
 * @param parent the {@code Container} hosting this LayoutManager
 * @throws IllegalArgumentException if {@code parent} is not
 *         the same {@code Container} that this was created with
 */
public void invalidateLayout(Container parent) {
    checkParent(parent);
    // invalidateLayout is called from Container.invalidate, which
    // does NOT grab the treelock.  All other methods do.  To make sure
    // there aren't any possible threading problems we grab the tree lock
    // here.
    synchronized(parent.getTreeLock()) {
        isValid = false;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:GroupLayout.java

示例14: 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

示例15: layoutContainer

import java.awt.Container; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param target
 *            Description of Parameter
 */
@Override
public void layoutContainer(Container target){
	synchronized(target.getTreeLock()){
		Insets insets=target.getInsets();
		int maxheight=target.getHeight()-(insets.top+insets.bottom+_vgap*2);
		int nmembers=target.getComponentCount();
		int y=0;
		
		Dimension preferredSize=preferredLayoutSize(target);
		Dimension targetSize=target.getSize();
		
		switch(_valign){
		case TOP:
			y=insets.top;
			break;
		case CENTER:
			y=(targetSize.height-preferredSize.height)/2;
			break;
		case BOTTOM:
			y=targetSize.height-preferredSize.height-insets.bottom;
			break;
		}
		
		for(int i=0;i<nmembers;i++){
			Component m=target.getComponent(i);
			if(m.isVisible()){
				Dimension d=m.getPreferredSize();
				m.setSize(d.width, d.height);
				
				if(y+d.height<=maxheight){
					if(y>0){
						y+=_vgap;
					}
					
					int x=0;
					switch(_halign){
					case LEFT:
						x=insets.left;
						break;
					case CENTER:
						x=(targetSize.width-d.width)/2;
						break;
					case RIGHT:
						x=targetSize.width-d.width-insets.right;
						break;
					}
					
					m.setLocation(x, y);
					
					y+=d.getHeight();
					
				}else{
					break;
				}
			}
		}
	}
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:65,代码来源:VerticalFlowLayout.java


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