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


Java Component.setSize方法代码示例

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


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

示例1: setComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Set the cell renderer we will proxy.
 */
public void setComponent (Component jc, JComponent owner) {
    Dimension dd = jc.getPreferredSize();
    Rectangle currentScreenBounds = Utilities.getUsableScreenBounds();
    // get some reasonable limit for the width
    int width = Math.min(dd.width, 2 * currentScreenBounds.width);
    int height = Math.min(dd.height + 2, 2 * currentScreenBounds.height);
    Image nue = !Utilities.isMac() ? owner.createVolatileImage(width, height) :
                new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics g = nue.getGraphics();
    g.setColor (bg);
    g.fillRect (0, 0, width, dd.height + 2);
    if( jc instanceof Container && !jc.isValid() ) {
        //#214739
        jc.setSize( width, dd.height );
        jc.doLayout();
    }
    SwingUtilities.paintComponent(g, jc, this, 0, 0, width, dd.height + 2);
    g.dispose();
    setImage (nue);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ViewTooltips.java

示例2: createMenuIcon

import java.awt.Component; //导入方法依赖的package包/类
private static Icon createMenuIcon(Icon icon, Component decorator) {
    int h = menuIconSize();
    int w = UIUtils.isAquaLookAndFeel() ? h + 4 : h;

    BufferedImage i = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    Graphics g = i.getGraphics();

    if (decorator != null) {
        decorator.setSize(w, h);
        decorator.paint(g);
    }

    icon.paintIcon(null, g, (w - icon.getIconWidth()) / 2, (h - icon.getIconHeight()) / 2);
    g.dispose();

    return new ImageIcon(i);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ToggleButtonMenuItem.java

示例3: getRenderer

import java.awt.Component; //导入方法依赖的package包/类
Component getRenderer(TableCellRenderer renderer, int row, int column, boolean sized) {
        isCustomRendering = true;
        try {
            Component comp = prepareRenderer(renderer, row, column);
//            comp.setSize(comp.getPreferredSize().width, getRowHeight());
            if (sized) {
                comp.setSize(comp.getPreferredSize().width, getRowHeight());
                if (!isLeadingAlign(comp)) {
                    TableColumnModel m = getColumnModel();
                    int x = -comp.getWidth();
                    int c = m.getColumn(column).getWidth();
                    int _column = convertColumnIndexToModel(column);
                    if (isScrollableColumn(_column)) {
                        x += Math.max(c, getColumnPreferredWidth(_column));
                    } else {
                        x += c;
                    }
                    comp.move(x - m.getColumnMargin(), 0);
                }
            }
            
            return comp;
        } finally {
            isCustomRendering = false;
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ProfilerTable.java

示例4: layoutContainer

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

示例5: ensureMinimumSize

import java.awt.Component; //导入方法依赖的package包/类
public static void ensureMinimumSize(Component c, int width, int height)
{
	Dimension size = c.getSize();

	if( size.width < width )
	{
		size.width = width;
	}

	if( size.height < height )
	{
		size.height = height;
	}

	c.setSize(size);
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:ComponentHelper.java

示例6: ensureMaximumSize

import java.awt.Component; //导入方法依赖的package包/类
public static void ensureMaximumSize(Component c, int width, int height)
{
	Dimension size = c.getSize();

	if( size.width > width )
	{
		size.width = width;
	}

	if( size.height > height )
	{
		size.height = height;
	}

	c.setSize(size);
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:ComponentHelper.java

示例7: add

import java.awt.Component; //导入方法依赖的package包/类
@Override
public Component add(Component comp) {
    setsize(comp.getPreferredSize());
    Component[] comps = getComponents();
    if (comps.length > 0) {
        oldComponent = comps[0];
    }
    if (comp.equals(oldComponent)) {
        return super.add(comp);
    }
    if (oldComponent != null) {
        putLayer((JComponent) oldComponent, JLayeredPane.DEFAULT_LAYER);
    }
    Component returnResult = super.add(comp);
    putLayer((JComponent) comp, JLayeredPane.DRAG_LAYER);
    comp.setSize(getPreferredSize());
    comp.setVisible(true);
    comp.setLocation(0, 0 - getPreferredSize().height);
    slideFromTop(comp, oldComponent);
    return returnResult;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:SlideContainer.java

示例8: setAllSizes

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Set min max and preferred size for a component
 * @param c
 * @param d
 */
private static void setAllSizes(Component c, Dimension d) {
	c.setPreferredSize(d);
	c.setMaximumSize(d);
	c.setMinimumSize(d);
	c.setSize(d);
}
 
开发者ID:fatmanspanda,项目名称:SpriteAnimator,代码行数:12,代码来源:AnimatorGUI.java

示例9: reapplyFontSize

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Apply the font size to the labels of a slider. This must be called after
 * the labels of a slider are changed.
 *
 * First set up the label hash table and add it to the slider. Then, after
 * the slider has been added to a parent window and had its UI assigned,
 * call this method to change the label sizes.
 *
 * http://nadeausoftware.com/node/93#Settingsliderlabelfontsizes
 * 
 * @param slider
 */
public static void reapplyFontSize(JSlider slider) {

    Font font = slider.getFont();
    Dictionary dict = slider.getLabelTable();
    Enumeration keys = dict.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Component label = (Component) dict.get(key);
        label.setFont(font);
        label.setSize(label.getPreferredSize());
    }

}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:26,代码来源:SliderUtils.java

示例10: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        child.setSize(compSize.width, compSize.height);
        child.setLocation(xInset + insets.left, height);
        height += compSize.height + yGap;
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:MetalworksPrefs.java

示例11: run

import java.awt.Component; //导入方法依赖的package包/类
@Override
public void run() {
    JTabbedPane pane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    pane.addTab("first", new JButton("first"));
    pane.addTab("second", new JButton("second"));
    for (Component component : pane.getComponents()) {
        component.setSize(100, 100);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Test6943780.java

示例12: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Lays out the container.
 *
 * @param target
 *            the container to lay out.
 */
public void layoutContainer(Container target) {
	Insets insets = target.getInsets();
	int maxheight = target.getSize().height
			- (insets.top + insets.bottom + vgap * 2);
	int maxwidth = target.getSize().width
			- (insets.left + insets.right + hgap * 2);
	int numcomp = target.getComponentCount();
	int x = insets.left + hgap, y = 0;
	int colw = 0, start = 0;

	for (int i = 0; i < numcomp; i++) {
		Component m = target.getComponent(i);
		if (m.isVisible()) {
			Dimension d = m.getPreferredSize();
			// fit last component to remaining height
			if ((this.vfill) && (i == (numcomp - 1))) {
				d.height = Math.max((maxheight - y),
						m.getPreferredSize().height);
			}

			// fit component size to container width
			if (this.hfill) {
				m.setSize(maxwidth, d.height);
				d.width = maxwidth;
			} else {
				m.setSize(d.width, d.height);
			}

			if (y + d.height > maxheight) {
				placethem(target, x, insets.top + vgap, colw,
						maxheight - y, start, i);
				y = d.height;
				x += hgap + colw;
				colw = d.width;
				start = i;
			} else {
				if (y > 0)
					y += vgap;
				y += d.height;
				colw = Math.max(colw, d.width);
			}
		}
	}
	placethem(target, x, insets.top + vgap, colw, maxheight - y, start,
			numcomp);
}
 
开发者ID:Harlber,项目名称:Method_Trace_Tool,代码行数:53,代码来源:VerticalFlowLayout.java

示例13: layoutContainer

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

示例14: getRenderer

import java.awt.Component; //导入方法依赖的package包/类
private Component getRenderer(int row, int column) {
    TableCellRenderer renderer = table.getCellRenderer(row, column);
    Component _renderer = table.getRenderer(renderer, row, column, true);
    _renderer.setSize(Math.min(_renderer.getWidth(), MAX_RENDERER_WIDTH), _renderer.getHeight());
    return _renderer;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:ProfilerTableHovers.java

示例15: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Description of the Method
 *
 * @param target Description of Parameter
 */
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:TheCaveCz,项目名称:letsmake-ledmatrix,代码行数:63,代码来源:VerticalFlowLayout.java


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