小编Con*_*orR的帖子

在java awt或swing中,我如何安排键盘输入去鼠标的哪里?

在帮助系统上工作,我希望每个组件在鼠标悬停时提供一些帮助并且"?" 键是按下的.有点像工具提示,除了更广泛的帮助 - 基本上一个小的Web浏览器旨在弹出和显示文本,图像或更多.

我发现无论鼠标在哪里,输入总是转到同一个KeyListener.是否应该一次只有一个活动?

对于它的价值,这是现在正在运行的版本 - 感谢您的建议!

    /**
     * Main class JavaHelp wants to support a help function so that when
     * the user types F1 above a component, it creates a popup explaining
     * the component.
     * The full version is intended to be a big brother to tooltips, invoking
     * an HTML display with clickable links, embedded images, and the like.
     */


    import javax.swing.*;
    import javax.swing.border.Border;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import …

java swing awt awt-eventqueue

6
推荐指数
1
解决办法
947
查看次数

scala:函数和函数_之间的区别

在 Scala 中使用按名称调用函数时,我遇到了一些意外行为。有人能解释一下这里的区别吗?

class Button( act: => Unit) {def fire = act}
def foo() {println("foo got called")}
val x= new Button(foo)
x.fire
val y= new Button(foo _)
y.fire
Run Code Online (Sandbox Code Playgroud)

x.fire 导致 foo 被调用。y.fire 没有。为什么?什么函数被传递给 y?谢谢!

scala

4
推荐指数
1
解决办法
246
查看次数

标签 统计

awt ×1

awt-eventqueue ×1

java ×1

scala ×1

swing ×1