0
任何人都请告诉我如何创建对象ActionEvent class java ??以及如何使用方法的ActionEvent类如何在java中创建ActionEvent类的对象?
任何人都请告诉我如何创建对象ActionEvent class java ??以及如何使用方法的ActionEvent类如何在java中创建ActionEvent类的对象?
请做更多描述性的你想做什么。
但这里是两种不同类型的使用一个ActionEvent
如果您正在使用JComponents的样本,并希望将其添加到按钮,也许其他的东西,我有线索只是做
component.addActionListener(new ActionListener()
{
//import the ActionListener and then you will be prompted to add an actionPerformed method
});
如果你想创建一个类,只需要做这样的事情。
private class Listener1 implements ActionListener
{
//again it will ask that you import it if not already imported and add the method actionPerformed(ActionEvent e) which is where you will put your code
}
然后在你的代码做
object.addActionListener(new Listener1());
不知道你问的,所以我希望上面的一些代码有助于
什么是你想达到什么地方?您需要对您面临的问题进行更具描述性的分析,并分享您的尝试,以便我们能够更好地为您提供帮助! – Ritikesh
'ActionEvent e = ActionEvent(source,ActionEvent.ACTION_PERFORMED,“command”);'是答案。但我不确定问题是什么。你应该清楚地说明你将如何处理这个事件。 – Marco13