我正在使用Swing开发游戏,我正在使用KeyBindings来输入键盘输入.
我遇到了KeyBindings停止响应的问题.每次运行应用程序时都会发生这种情况,但据我所知,并不是某个事件链发生时.KeyBindings只是停止接收来自键盘的输入.我也使用鼠标输入,它继续工作,所以我知道它与输入无关.
我试过的一些事情:
KeyListener改用这些都没有奏效.
然后我将项目(不更改任何代码)复制到Windows机器上,经过测试,我无法解决问题.我没有粘贴代码,因为我99%肯定这与我的代码无关,但与运行的操作系统有关.
这是macOS,JDK for Mac或其他我不知道的问题吗?
我正在使用JDK版本8更新112,计算机正在运行macOS Sierra版本10.12.2.
似乎其他人我现在遇到了同样的问题,但他们从来没有得到答案.
编辑
以下是出现问题的代码示例:
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
//an example of the problem where the keyboard stops receiving input randomly
public class ProblemExample extends JPanel {
private static final long serialVersionUID = 1L;
private int xPos = 200, …Run Code Online (Sandbox Code Playgroud) 我在 Debian GNU/Linux 8 (jessie) 64 位下使用 Python 2.7.9。我只是尝试通过调用os.chflags(path, mode). 在 Python 文档中,有一篇关于os接口的文章说该方法在Unix 中可用,但不适用于 Linux。Python 总是抛出:
Traceback (most recent call last):
File "/home/lexer/py/epam/tests/main.py", line 43, in <module>
os.chflags(path_to_file(file_name), stat.SF_NOUNLINK)
AttributeError: 'module' object has no attribute 'chflags'
Run Code Online (Sandbox Code Playgroud)
很久以前就已经提出了一个问题,但我仍然无法理解为什么os.chflags()不执行chattr命令的工作。有人能详细说明一下吗?