Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在用 Java 制作连接四游戏。我得到了 6*7 布局和声音组件。我想要做的是有空心圆圈,当你点击一个空心圆圈时,它会填充玩家的颜色并且不能再次点击。我不确定如何在这样一个特定区域触发事件。欢迎任何提示或建议:)
阅读有关 MouseMotionListener、MouseListener 的信息。您可以获取鼠标坐标,并且可以知道用户是否单击了鼠标。当用户在特定区域单击时,例如 (x>20, x<30, y>20, y<40) 使用paintComponent 方法绘制具有特定颜色的圆。