本文整理汇总了Java中java.awt.Component.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getY方法的具体用法?Java Component.getY怎么用?Java Component.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.getY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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);
}
示例3: 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();
}
示例4: 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);
}