您将如何处理扩展 JPanel 的自定义摆动组件中的单击。我正在制作游戏,我想知道如何处理点击。特别是在与gui不同的线程中,并且绘画?我将如何做到这一点是我的代码:
package com.games.bubblecards;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;
public class Canvas extends JPanel {
private static final long serialVersionUID = 1L;
public Canvas() {
super();
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.drawString("Hello It Works", 10, 10);
}
}