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


Java Component.setBounds方法代码示例

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


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

示例1: updateCellOverlayComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Notified when an overlay has been removed from the graph. This implementation removes the given
 * overlay from its parent if it is a component inside a component hierarchy.
 */
protected void updateCellOverlayComponent(mxCellState state, mxICellOverlay overlay) {
  if (overlay instanceof Component) {
    Component comp = (Component) overlay;

    if (comp.getParent() == null) {
      getGraphControl().add(comp, 0);
    }

    mxRectangle rect = overlay.getBounds(state);

    if (rect != null) {
      comp.setBounds(rect.getRectangle());
      comp.setVisible(true);
    } else {
      comp.setVisible(false);
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:23,代码来源:mxGraphComponent.java

示例2: stateChanged

import java.awt.Component; //导入方法依赖的package包/类
public void stateChanged(ChangeEvent e) {
    if (container.isShowing() 
     //a special case for property sheet dialog window - the selection 
     //change must be processed otherwise the tabbed container may have
     //undefined preferred size so the property window will be too small
     || container.getClientProperty("tc") != null) { //NOI18N
        int idx = tabDisplayer.getSelectionModel().getSelectedIndex();
        if (idx != -1) {
            Component c = toComp(container.getModel().getTab(idx));
            c.setBounds(0, 0, contentDisplayer.getWidth(),
                        contentDisplayer.getHeight());
            showComponentWithFxProvider(c);
        } else {
            showComponent (null);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DefaultTabbedContainerUI.java

示例3: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
@Override
public void layoutContainer(Container parent) {
    int x = 0;
    int y = 0;
    int cellWidth = getMaxCellWidth();
    for (Component c : this.components) {
        if (c.isVisible()) {
            Dimension d = c.getPreferredSize();
            if (y + d.height > parent.getHeight()) {
                x += cellWidth;
                y = 0;
            }
            c.setBounds(x + 1, y + 1, cellWidth, d.height);
            y += d.height;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:VerticalGridLayout.java

示例4: paintComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Paints the current state (i.e. the state corresponding to the current
 * phase) of the given component.
 *
 * @param g graphics context.
 * @param comp component to paint.
 */
private void paintComponent(Graphics g, Component comp) {
    Rectangle bounds = currentBounds(comp);
    float alpha = currentAlpha(comp);
    Graphics gg = g.create(bounds.x, bounds.y, bounds.width, bounds.height);
    if (alpha != 1f) {
        AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
        ((Graphics2D)gg).setComposite(alphaComposite);
    }
    comp.setBounds(bounds);
    comp.validate();
    // Intentionally using print instead of paint.
    // Print doesn't use double buffering and it solves some mysterious
    // problems with modified clip during painting of containers.
    // BTW: animated transitions library also uses print()
    if (comp instanceof JComponent) {
        comp.print(gg);
    } else {
        java.awt.peer.ComponentPeer peer = FakePeerSupport.getPeer(comp);
        if (peer != null) {
            peer.paint(gg);
        }
    }
    gg.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:AnimationLayer.java

示例5: layout

import java.awt.Component; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void layout() {
    Insets ins = getInsets();

    //use a minimum size so typical icons won't cause resizing of the
    //component
    int iconWidth = Math.max(icon.getIconWidth() + PropUtils.getTextMargin(), 18);

    int x = (icon == null) ? ins.left : (ins.left + iconWidth);
    int y = ins.top;

    synchronized (getTreeLock()) {
        Component c = comp;

        if (c == null) {
            return;
        }

        c.setBounds(x, y, getWidth() - (x + ins.right), getHeight() - ins.bottom);

        if (c instanceof Container) {
            ((Container) c).doLayout();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:IconPanel.java

示例6: updateCellOverlayComponent

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Notified when an overlay has been removed from the graph. This
 * implementation removes the given overlay from its parent if it is a
 * component inside a component hierarchy.
 */
protected void updateCellOverlayComponent(mxCellState state,
		mxICellOverlay overlay)
{
	if (overlay instanceof Component)
	{
		Component comp = (Component) overlay;

		if (comp.getParent() == null)
		{
			getGraphControl().add(comp, 0);
		}

		mxRectangle rect = overlay.getBounds(state);

		if (rect != null)
		{
			comp.setBounds(rect.getRectangle());
			comp.setVisible(true);
		}
		else
		{
			comp.setVisible(false);
		}
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:31,代码来源:mxGraphComponent.java

示例7: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
public void layoutContainer(final Container parent) {
    final Insets insets = parent.getInsets();
    int posX = insets.left;
    final int posY = insets.top;
    final int height = parent.getHeight() - insets.top - insets.bottom;

    for (Component comp : parent.getComponents()) {
        if (comp.isVisible()) {
            Dimension pref = comp.getPreferredSize();
            if (proportionalHeight) {
                int h = Math.min(pref.height, height);
                int o = (height - h) / 2;
                comp.setBounds(posX, posY + o, pref.width, h);
            } else {
                comp.setBounds(posX, posY, pref.width, height);
            }
            posX += hGap;
            posX += pref.width;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:HorizontalLayout.java

示例8: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
public void layoutContainer(Container target) {
  super.layoutContainer(target);
  base.getLayout().layoutContainer(base);

  final Dimension viewSize = base.getViewport().getSize();
  final Insets insets = base.getInsets();
  viewSize.width += insets.left;
  viewSize.height += insets.top;

  // prevent non-base components from overlapping the base's scrollbars
  final int n = target.getComponentCount();
  for (int i = 0; i < n; ++i) {
    Component c = target.getComponent(i);
    if (c != base && c.isVisible()) {
      final Rectangle b = c.getBounds();
      b.width = Math.min(b.width, viewSize.width);
      b.height = Math.min(b.height, viewSize.height);
      c.setBounds(b);
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:22,代码来源:Map.java

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

示例10: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
public void layoutContainer(Container parent) {
    setParent(parent);

    int n = parent.getComponentCount();
    getConstraints(parent).reset();
    for (int i = 0 ; i < n ; i++) {
        getConstraints(parent.getComponent(i)).reset();
    }

    Insets insets = parent.getInsets();
    Constraints pc = getConstraints(parent);
    abandonCycles(pc.getX()).setValue(0);
    abandonCycles(pc.getY()).setValue(0);
    abandonCycles(pc.getWidth()).setValue(parent.getWidth() -
                                          insets.left - insets.right);
    abandonCycles(pc.getHeight()).setValue(parent.getHeight() -
                                           insets.top - insets.bottom);

    for (int i = 0 ; i < n ; i++) {
        Component c = parent.getComponent(i);
        Constraints cc = getConstraints(c);
        int x = abandonCycles(cc.getX()).getValue();
        int y = abandonCycles(cc.getY()).getValue();
        int width = abandonCycles(cc.getWidth()).getValue();
        int height = abandonCycles(cc.getHeight()).getValue();
        c.setBounds(insets.left + x, insets.top + y, width, height);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:SpringLayout.java

示例11: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
@Override
public void layoutContainer(Container parent) {
    StyledDocument doc = (StyledDocument)editor.getDocument();
    for (Component comp : parent.getComponents()) {
        Position pos = positions.get(comp);
        int line = findLineNumber(doc, pos.getOffset());
        Dimension prefSize = comp.getPreferredSize();
        int dy = lineHeight() - prefSize.height;
        dy = dy > 0 ? dy / 2 + 1 : 0;
        comp.setBounds(LEFT_GAP,
                       line * lineHeight() + dy,
                       parent.getWidth() - LEFT_GAP - RIGHT_GAP,
                       Math.min(prefSize.height, lineHeight()));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CustomCodeView.java

示例12: paintComponent

import java.awt.Component; //导入方法依赖的package包/类
/** Workaround for excessive paints by SwingUtilities.paintComponent() */
private void paintComponent(Graphics g, Component c, int x, int y, int w, int h) {
    c.setBounds(x, y, w, h);
    g.translate(x, y);
    c.paint(g);
    g.translate(-x, -y);
    c.setBounds(-w, -h, 0, 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:SheetTable.java

示例13: setBounds

import java.awt.Component; //导入方法依赖的package包/类
private void setBounds(Component c, int x, int y, int width, int height)
{
	if( c != null )
	{
		c.setBounds(x, y, width, height);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:8,代码来源:FlatterSpinnerUI.java

示例14: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
@Override
public void layoutContainer(Container parent) {
	Dimension size = parent.getSize();
	Insets insets = parent.getInsets();
	int itop = insets.top;
	int ileft = insets.left;
	int ibottom = insets.bottom;
	int iright = insets.right;

	int rightWidth = right.getPreferredSize().width;
	int bottomHeight = bottom.getPreferredSize().height;
	int centerWidth = size.width - rightWidth - ileft - iright;
	int centerHeight = size.height - bottomHeight - itop - ibottom;

	center.setBounds(ileft, itop, centerWidth, centerHeight);

	right.setBounds(ileft + centerWidth, itop, rightWidth, centerHeight);

	// Lay out all status components, in order
	Enumeration status = leftOfScrollBar.elements();
	while (status.hasMoreElements()) {
		Component comp = (Component) status.nextElement();
		Dimension dim = comp.getPreferredSize();
		comp.setBounds(ileft, itop + centerHeight, dim.width, bottomHeight);
		ileft += dim.width;
	}

	bottom.setBounds(ileft, itop + centerHeight, size.width - rightWidth - ileft - iright, bottomHeight);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:30,代码来源:JEditTextArea.java

示例15: layoutContainer

import java.awt.Component; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    int maxWidth = parent.getWidth() - (insets.left + insets.right);
    int maxHeight = parent.getHeight() - (insets.top + insets.bottom);
    int width = 0;
    int height = 0;

    width = ((maxWidth - gap * (MAX_COLUMNS + 1)) / MAX_COLUMNS);
    height = ((maxHeight - gap * (MAX_ROWS + 1)) / MAX_ROWS);
    componentDimension = new Dimension(width, height);

    for (Component comp : parent.getComponents()) {
        RCPosition position = components.get(comp);
        int row = position.getRow();
        int column = position.getColumn();
        if (position != null) {
            int x = insets.left + column * gap + (column - 1)
                    * componentDimension.width;
            int y = insets.top + row * gap + (row - 1)
                    * componentDimension.height;
            if (row == 1 && column == 1) {
                comp.setBounds(x, y,
                        componentDimension.width * 5 + 4 * gap,
                        componentDimension.height);
            } else {
                comp.setBounds(x, y, componentDimension.width,
                        componentDimension.height);
            }
        }
    }
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:35,代码来源:CalcLayout.java


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