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


Java Form.getComponentAt方法代码示例

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


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

示例1: mouseMoved

import com.codename1.ui.Form; //导入方法依赖的package包/类
public void mouseMoved(MouseEvent e) {
    Form f = Display.getInstance().getCurrent();
    if (f != null) {
        com.codename1.ui.Component c = f.getComponentAt(e.getX(), e.getY());
        if (c != null) {
            try {
                String tip = c.getUIID();
                lastComponentFocus = c.hasFocus();
                com.codename1.ui.Container parent = c.getParent();

                // the code above shows softbuttons as buttons rather than as softbuttons
                // which is not quite what we want...
                if (parent != null && parent instanceof com.codename1.ui.MenuBar) {
                    // special case for title which falls into the gray area
                    if (!tip.equals("Title") || tip.equals("DialogTitle")) {
                        String parentTip = parent.getUIID();
                        if (parentTip != null) {
                            tip = parentTip;
                        }
                    }
                }

                lastComponent = tip;
                previewPanel.setToolTipText(tip);
                return;
            } catch (Exception err) {
                // shouldn't happen
                err.printStackTrace();
            }
        }
    }
    setToolTipText("");
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:34,代码来源:ThemeEditor.java

示例2: sendToCn1

import com.codename1.ui.Form; //导入方法依赖的package包/类
private boolean sendToCn1(MouseEvent e) {
    
    int cn1X = getCN1X(e);
    int cn1Y = getCN1Y(e);
    if ((!peerGrabbedDrag || true) && Display.isInitialized()) {
        Form f = Display.getInstance().getCurrent();
        if (f != null) {
            Component cmp = f.getComponentAt(cn1X, cn1Y);
            //if (!(cmp instanceof PeerComponent) || cn1GrabbedDrag) {
                // It's not a peer component, so we should pass the event to the canvas
                e = SwingUtilities.convertMouseEvent(this, e, canvas);
                switch (e.getID()) {
                    case MouseEvent.MOUSE_CLICKED:
                        canvas.mouseClicked(e);
                        break;
                    case MouseEvent.MOUSE_DRAGGED:
                        canvas.mouseDragged(e);
                        break;
                    case MouseEvent.MOUSE_MOVED:
                        canvas.mouseMoved(e);
                        break;
                    case MouseEvent.MOUSE_PRESSED:
                        // Mouse pressed in native component - passed to lightweight cmp
                        if (!(cmp instanceof PeerComponent)) {
                            cn1GrabbedDrag = true;
                        }
                        canvas.mousePressed(e);
                        break;
                    case MouseEvent.MOUSE_RELEASED:
                        cn1GrabbedDrag = false;
                        canvas.mouseReleased(e);
                        break;
                    case MouseEvent.MOUSE_WHEEL:
                        canvas.mouseWheelMoved((MouseWheelEvent)e);
                        break;
                        
                }
                //return true;
                if (cn1GrabbedDrag) {
                    return true;
                }
                if (cmp instanceof PeerComponent) {
                    return false;
                }
                return true;
            //}
        }
    }
    if (e.getID() == MouseEvent.MOUSE_RELEASED) {
        cn1GrabbedDrag = false;
        peerGrabbedDrag = false;
    } else if (e.getID() == MouseEvent.MOUSE_PRESSED) {
        peerGrabbedDrag = true;
    }
    return false;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:57,代码来源:JavaSEPort.java


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