澄清对Action-event、constructor的理解 [英] clarify understanding of Action-event, constructor

查看:34
本文介绍了澄清对Action-event、constructor的理解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这些问题感到困惑,我只是想知道是否有人看到我做对了.

I'm confuse on these questions, I was just wondering if anyone see if I'm doing them right.

如果您想创建像橡皮筋线这样的效果,它会随着用户输入,您很可能需要一个 (an)A. 鼠标监听器B. 动作监听器C. 鼠标适配器D. MouseMotionListenerE. KeyListener

If you want to create an effect like a rubber-band line, which changes continually with user input, you will most likely need a (an) A. MouseListener B. ActionListener C. MouseAdapter D. MouseMotionListener E. KeyListener

我认为答案是动作侦听器,因为对象正在观察的任何内容都会生成动作事件.

I think the answer is action listener because what ever the object is observing generate a action event.

S假设程序员创建了一个名为 MyFrame 的 Java 类,它扩展了 JFrame.MyFrame 类包含一个主体为空的构造函数.如果一个对象创建类型 MyFrame 并使其可见(但对象中没有其他方法调用),然后当用户点击窗口右上角的X"(框架),

A.程序将终止

B.窗口将被隐藏但仍然存在

B. the window will be hidden but will still exist

C.窗口将关闭

D.窗口将被最小化(图标化")

D. the window will be minimized ("iconified")

E.这个问题无法回答,因为这样的类无法编译

E. the question cannot be answered because such a class cannot be compiled

F.无法从给出的信息中确定答案

F. the answer cannot be determined from the information given

假设我理解正确的问题.因此 MyFram 类扩展到 JFrame.而我的类 MyFrame { } 构造函数是空的.我认为它 B,因为它会编译,但可能不会做任何形式的动作,假设根本没有调用任何东西.

Assuming I understood the questions right. So the class MyFram extends to JFrame. And my class MyFrame { } constructor is empty. I think it B, because it will compile, but may not doing any form of action assuming nothing is invoked at all.

推荐答案

A MouseMotionListener,例如橡皮筋选择这里的例子中,允许查看将在 mouseDragged() 的实现中更新.

A MouseMotionListener, such as the MouseMotionHandler used during rubber band selection in the example cited here, allows the view to be updated in its implementation of mouseDragged().

private class MouseMotionHandler extends MouseMotionAdapter {
    …
    @Override
    public void mouseDragged(MouseEvent e) {
        …
        e.getComponent().repaint();
    }
}

这篇关于澄清对Action-event、constructor的理解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆