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


Java Component.getBounds方法代码示例

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


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

示例1: init

import java.awt.Component; //导入方法依赖的package包/类
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:WPrinterJob.java

示例2: getBounds

import java.awt.Component; //导入方法依赖的package包/类
Rectangle getBounds() {
    Rectangle bounds = null;
    TopComponent modeTC = getTopComponent();
    if( null == modeTC ) {
        modeTC = mode.getSelectedTopComponent();
        if( null == modeTC ) {
            TopComponent[] tcs = mode.getTopComponents();
            if( null != tcs && tcs.length > 0 )
                modeTC = tcs[0];
        }
    }
    Component modeComp = ( Component ) SwingUtilities.getAncestorOfClass(ModeComponent.class, modeTC);
    if( modeComp != null ) {
        bounds = modeComp.getBounds();
    }
    return bounds;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TopComponentDraggable.java

示例3: getRendererRect

import java.awt.Component; //导入方法依赖的package包/类
private Rectangle getRendererRect(int column, Component renderer) {
    int _column = table.convertColumnIndexToModel(column);
    
    // Do not show value hovers for standard renderers shortening values using '...'
    if (!(renderer instanceof ProfilerRenderer) &&
        !table.isScrollableColumn(_column))
            return null;
    
    // Do not show value hovers when explicitely disabled
    if (renderer instanceof JComponent)
        if (((JComponent)renderer).getClientProperty(ProfilerTable.PROP_NO_HOVER) != null)
            return null;
    
    Rectangle bounds = renderer.getBounds();
    bounds.x -= table.getColumnOffset(_column);
    
    return bounds;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProfilerTableHovers.java

示例4: getPreferredHeight

import java.awt.Component; //导入方法依赖的package包/类
private int getPreferredHeight() {
	int rv = 0;
	for (int k = 0, count = getComponentCount(); k < count; k++) {
		Component comp = getComponent(k);
		Rectangle r = comp.getBounds();
		int height = r.y + r.height;
		if (height > rv) {
			rv = height;
		}
	}

	if (getParent().getHeight() > rv) {
		return getParent().getHeight();
	} else {
		return rv;
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:18,代码来源:WarningWindow.java

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

示例6: removeFromCanvas

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Removes the given component from this canvas.
 *
 * @param comp The {@code Component} to remove.
 */
public void removeFromCanvas(Component comp) {
    if (comp == null) return;

    final Rectangle updateBounds = comp.getBounds();
    final JInternalFrame frame = getInternalFrame(comp);
    notifyClose(comp, frame);
    if (frame != null && frame != comp) {
        frame.dispose();
    } else {
        // Java 1.7.0 as seen on Fedora with:
        //   Java version: 1.7.0_40
        //   Java WM version: 24.0-b56
        // crashes here deep in the java libraries.
        try {
            super.remove(comp);
        } catch (Exception e) {
            logger.log(Level.WARNING, "Java crash", e);
        }
    }
    repaint(updateBounds.x, updateBounds.y,
            updateBounds.width, updateBounds.height);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:28,代码来源:Canvas.java

示例7: retrieveComponentInfo

import java.awt.Component; //导入方法依赖的package包/类
private ComponentInfo retrieveComponentInfo(Component c, int shiftx, int shifty) {
    String name = c.getName();
    c.getBounds(rectangle);
    int x = rectangle.x;
    int y = rectangle.y;
    if (shiftx == Integer.MIN_VALUE && shifty == Integer.MIN_VALUE) {
        shiftx = shifty = 0; // Do not shift the window as such
        x = y = 0;
    } else {
        shiftx += x;
        shifty += y;
    }
    ComponentInfo ci = new ComponentInfo(c, name, x, y,
                                         rectangle.width, rectangle.height,
                                         shiftx, shifty,
                                         c.isVisible());
    if (c instanceof Container) {
        Component[] subComponents = ((Container) c).getComponents();
        int n = subComponents.length;
        if (n > 0) {
            ComponentInfo[] cis = new ComponentInfo[n];
            for (int i = 0; i < cis.length; i++) {
                cis[i] = retrieveComponentInfo(subComponents[i], shiftx, shifty);
            }
            ci.setSubcomponents(cis);
        }
    }
    return ci;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:RemoteAWTService.java

示例8: mouseMoved

import java.awt.Component; //导入方法依赖的package包/类
public void mouseMoved(MouseEvent e) {
    check(e);
    Component comp = (Component)e.getSource();
    movedBounds = comp.getBounds(movedBounds);

    cursorType = getCursorType(movedBounds, e.getPoint());
    comp.setCursor(Cursor.getPredefinedCursor(cursorType));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DecorationUtils.java

示例9: doLayout

import java.awt.Component; //导入方法依赖的package包/类
public void doLayout() {
    super.doLayout();
    Component c = getComponent(1);
    
    int h = c.getPreferredSize().height;
    Rectangle b = c.getBounds();
    
    b.y = (b.height - h) / 2;
    b.height = h;
    c.setBounds(b);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:TitledMenuSeparator.java

示例10: getRendererRect

import java.awt.Component; //导入方法依赖的package包/类
private Rectangle getRendererRect(int row, int column) {
    Component component = getRenderer(row, column);
    
    if (component instanceof JComponent)
        if (((JComponent)component).getClientProperty(ProfilerTable.PROP_NO_HOVER) != null)
            return null;
    
    Rectangle bounds = component.getBounds();
    bounds.x -= table.getColumnOffset(table.convertColumnIndexToModel(column));
    
    return bounds;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ProfilerTableHover.java

示例11: scrollEnd

import java.awt.Component; //导入方法依赖的package包/类
private void scrollEnd(JScrollPane scrollpane) {
    JViewport vp = scrollpane.getViewport();
    Component view;
    if (vp != null && (view = vp.getView()) != null) {
        Rectangle visRect = vp.getViewRect();
        Rectangle bounds = view.getBounds();
        if (scrollpane.getComponentOrientation().isLeftToRight()) {
            vp.setViewPosition(new Point(bounds.width - visRect.width,
                                     bounds.height - visRect.height));
        } else {
            vp.setViewPosition(new Point(0,
                                     bounds.height - visRect.height));
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:BasicScrollPaneUI.java

示例12: scrollHome

import java.awt.Component; //导入方法依赖的package包/类
private void scrollHome(JScrollPane scrollpane) {
    JViewport vp = scrollpane.getViewport();
    Component view;
    if (vp != null && (view = vp.getView()) != null) {
        if (scrollpane.getComponentOrientation().isLeftToRight()) {
            vp.setViewPosition(new Point(0, 0));
        } else {
            Rectangle visRect = vp.getViewRect();
            Rectangle bounds = view.getBounds();
            vp.setViewPosition(new Point(bounds.width - visRect.width, 0));
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:BasicScrollPaneUI.java

示例13: Repainter

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Creates a <code>Repainter</code> for the specified component and area.
 *
 * @param c the component to be repainted
 * @param r the area to be repainted
 *
 * @throws IllegalArgumentException if <code>c == null</code>
 */
public Repainter(Component c, Rectangle r) {
  if (c == null) throw new IllegalArgumentException();
  this.c = c;

  if (r == null) r = c.getBounds();

  this.x = r.x;
  this.y = r.y;
  this.w = r.width;
  this.h = r.height;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:Repainter.java

示例14: customize

import java.awt.Component; //导入方法依赖的package包/类
boolean customize(final ValidityAwarePanel customizer, Runnable updater, boolean focusToEditor) {
    ValidityAwarePanel showingCustomizer = getShowingCustomizer();

    if (showingCustomizer != null) {
        ProfilerDialogs.displayWarning(
                Bundle.ProfilingPointsManager_AnotherPpEditedMsg());
        SwingUtilities.getWindowAncestor(showingCustomizer).requestFocus();
        showingCustomizer.requestFocusInWindow();
    } else {
        CustomizerButton cb = getCustomizerButton();
        customizer.addValidityListener(cb);
        cb.setEnabled(customizer.areSettingsValid()); // In fact customizer should be valid but just to be sure...

        JPanel customizerContainer = new JPanel(new BorderLayout());
        JPanel customizerSpacer = new JPanel(new BorderLayout());
        customizerSpacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0));
        customizerSpacer.add(customizer, BorderLayout.CENTER);
        customizerContainer.add(customizerSpacer, BorderLayout.CENTER);
        customizerContainer.add(new JSeparator(), BorderLayout.SOUTH);

        HelpCtx helpCtx = null;

        if (customizer instanceof HelpCtx.Provider) {
            helpCtx = ((HelpCtx.Provider) customizer).getHelpCtx();
        }

        DialogDescriptor dd = new DialogDescriptor(customizerContainer, Bundle.ProfilingPointsManager_PpCustomizerCaption(), false,
                                                   new Object[] { cb, DialogDescriptor.CANCEL_OPTION },
                                                   cb, 0, helpCtx, null);
        final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
        d.addWindowListener(new CustomizerListener(d, dd, updater));
        d.setModal(true);
        // give focus to the initial focus target
        d.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                if (customizer.getInitialFocusTarget() != null) {
                    customizer.getInitialFocusTarget().requestFocusInWindow();
                }
            }
        });
        
        if (focusToEditor) {
            Dimension dim = d.getPreferredSize();
            Component masterComponent = WindowManager.getDefault().getRegistry().getActivated();
            if (masterComponent != null) {
                Rectangle b = masterComponent.getBounds();
                Point location = new Point((b.x + (b.width / 2)) - (dim.width / 2),
                                           (b.y + (b.height / 2)) - (dim.height / 2));
                SwingUtilities.convertPointToScreen(location, masterComponent);
                d.setLocation(location);
            }
        }
        
        d.setVisible(true);
        
        if (dd.getValue() == cb) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:ProfilingPointsManager.java

示例15: computeBounds

import java.awt.Component; //导入方法依赖的package包/类
public void computeBounds (Component component) {
    bounds = component.getBounds();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:SummaryCellRenderer.java


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