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


Java Component.getX方法代码示例

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


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

示例1: getTextOffset

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Returns offset for the text.
 * BasicMenuItemUI sets max text offset on the JPopupMenuUI.
 * @param c PopupMenu to return text offset for.
 * @return text offset for the component
 */
static int getTextOffset(JComponent c) {
    int rv = -1;
    Object maxTextOffset =
        c.getClientProperty(BASICMENUITEMUI_MAX_TEXT_OFFSET);
    if (maxTextOffset instanceof Integer) {
        /*
         * this is in JMenuItem coordinates.
         * Let's assume all the JMenuItem have the same offset along X.
         */
        rv = (Integer) maxTextOffset;
        int menuItemOffset = 0;
        Component component = c.getComponent(0);
        if (component != null) {
            menuItemOffset = component.getX();
        }
        rv += menuItemOffset;
    }
    return rv;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:WindowsPopupMenuUI.java

示例2: contains

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Returns true if selectio contains a component
 * 
 * @param component
 * @return boolean
 */
public boolean contains(Component component) {
    int x = component.getX() - getX();
    int y = component.getY() - getY();
    return contains(x, y)
            || contains(x + component.getWidth(), y)
            || contains(x, y + component.getHeight())
            || contains(x + component.getWidth(), y + component.getHeight());
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:15,代码来源:JNodeContainerSelection.java

示例3: drawOpenSpotAtEndOfMenuBar

import java.awt.Component; //导入方法依赖的package包/类
private  void drawOpenSpotAtEndOfMenuBar(Graphics2D g2, JComponent mb) {
    Point mblocation = SwingUtilities.convertPoint(mb, new Point(0,0), this);
    if(mb.getComponentCount() > 0) {
        Component lastComp = mb.getComponent(mb.getComponentCount()-1);
        mblocation.x += lastComp.getX() + lastComp.getWidth();
    }
    g2.drawRect(mblocation.x+2, mblocation.y+2, mb.getHeight()-4, mb.getHeight()-4);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DropTargetLayer.java

示例4: showPopup

import java.awt.Component; //导入方法依赖的package包/类
public void showPopup(KeyEvent keyEvent) {
    if (isContextMenuOn()) {
        return;
    }
    Component component = keyEvent.getComponent();
    if (component instanceof JMenuItem && (!(component instanceof JMenu) || ((JMenu) component).isSelected())) {
        return;
    }
    Point point = new Point(component.getX() + component.getWidth() / 2, component.getY() + component.getHeight() / 2);
    showPopup(component, point);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:ContextMenuHandler.java

示例5: readPositionFromComponent

import java.awt.Component; //导入方法依赖的package包/类
private void readPositionFromComponent(Component component) {
	isFullScreen = false;
	windowWidth = component.getWidth();
	windowHeight = component.getHeight();
	windowX = component.getX();
	windowY = component.getY();
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:8,代码来源:WindowPosition.java

示例6: mousePressed

import java.awt.Component; //导入方法依赖的package包/类
@Override
public void mousePressed(MouseEvent e) {
    dragged = (Component) e.getSource();
    relativePosition = new Point(dragged.getX(), dragged.getY());
    relativePosition.translate(-e.getLocationOnScreen().x, -e.getLocationOnScreen().y);
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:7,代码来源:DragSupport.java


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