本文整理汇总了Java中java.awt.Component.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getLocation方法的具体用法?Java Component.getLocation怎么用?Java Component.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.getLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferredSize
import java.awt.Component; //导入方法依赖的package包/类
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
if(getItemCount() <= maximumFastChoices && size.width > maximumWidth) {
setSize(maximumWidth, Integer.MAX_VALUE);
doLayout();
int compCnt = getComponentCount();
if(compCnt > 0) {
Component lastComp = getComponent(compCnt - 1);
Point compLoc = lastComp.getLocation();
Dimension compSize = lastComp.getSize();
size.width = maximumWidth;
size.height = compLoc.y + compSize.height + getInsets().bottom;
}
}
return size;
}
示例2: paint
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
Rectangle r = getBounds();
g.setColor(Color.lightGray);
g.draw3DRect(0, 0, r.width, r.height, false);
int n = getComponentCount();
for (int i = 0; i < n; i++) {
Component comp = getComponent(i);
if (comp instanceof Checkbox) {
Point loc = comp.getLocation();
Dimension d = comp.getSize();
g.setColor(comp.getForeground());
g.drawRect(loc.x - 1, loc.y - 1, d.width + 1, d.height + 1);
}
}
}
示例3: getIconAt
import java.awt.Component; //导入方法依赖的package包/类
protected JInternalFrame.JDesktopIcon getIconAt(JDesktopPane desktop,
JInternalFrame.JDesktopIcon icon, int x, int y) {
JInternalFrame.JDesktopIcon currentIcon = null;
Component[] components = desktop.getComponents();
for (int i=0; i<components.length; i++) {
Component comp = components[i];
if (comp instanceof JInternalFrame.JDesktopIcon &&
comp != icon) {
Point p = comp.getLocation();
if (p.x == x && p.y == y) {
return (JInternalFrame.JDesktopIcon)comp;
}
}
}
return null;
}
示例4: paintDropGesture
import java.awt.Component; //导入方法依赖的package包/类
private void paintDropGesture( Graphics g ) {
Component c = toolbar.getComponentAtIndex( dropIndex );
if( null == c )
return;
Point location = c.getLocation();
int cursorLocation = location.x;
if( !dropBefore ) {
cursorLocation += c.getWidth();
if( dropIndex == toolbar.getComponentCount()-1 )
cursorLocation -= 3;
}
drawDropLine( g, cursorLocation );
}
示例5: WindowMover
import java.awt.Component; //导入方法依赖的package包/类
WindowMover(Component parent, Component component, int movePolicy) {
window = parent;
com = component;
loc = component.getLocation();
init(movePolicy);
addListeners(com);
}