當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。