JApplet 不停止或对键盘输入作出反应 [英] JApplet Not Stopping or Reacting to Keyboard Input

查看:17
本文介绍了JApplet 不停止或对键盘输入作出反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在忙于 awt/swing,试图学习如何制作小程序.

I've been messing around with awt/swing lately trying to learn how to do applets.

我编写了以下简短的 JApplet 示例代码,从表面上看似乎可行.

I have written the following short JApplet example code, which on the surface seems to work.

尝试退出时出现的问题:

The problems I have occur when I try to exit it:

  1. 按 ESC 什么也不做,实际上当我在调试器中运行它时,第 38 行从未到达(第 94 行也没有 - 似乎覆盖的函数 processKeyEvent(KeyEvent e) 没有被小程序运行程序在按键时调用一点).但是,似乎确实处理了鼠标事件(通过调试器,我可以看到移动鼠标时到达了第 99 行).
  2. 尝试关闭/退出 eclipse 的小程序运行程序会导致它挂起,这意味着我必须终止该进程.通过它运行另一个小程序时没有发生这种情况.
  3. 打印的@"大小不正确,我怀疑它没有使用我在第 74 行设置的固定宽度字体进行绘制.

知道我做错了什么吗?

-伊多.

推荐答案

看来你没有把焦点放在小程序上.当我在 eclipse 中运行它时,按 Esc 键什么也没做.但是当我在网格内点击时,按 Esc 就可以了.它在控制台中输出未运行".在 Eclipse 中关闭小程序也可以正常工作.您运行的是哪个 Eclipse 版本以及哪个 Java 版本?

It seems that you have not given focus to the applet. When i run it in eclipse, pressing escape does nothing. but when i have clicked inside the grid, pressing escape works just fine. it outputs "not running" in the console. Also closing the applet in eclipse works just fine. Which eclipse version are you running and what Java version?

这篇关于JApplet 不停止或对键盘输入作出反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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