Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java中特定于时间的actionListener_Java_Awt_Actionlistener - Fatal编程技术网

java中特定于时间的actionListener

java中特定于时间的actionListener,java,awt,actionlistener,Java,Awt,Actionlistener,我想写一个特定于时间的actionListener,它在特定时间触发一些动作。我知道java中有ScheduledExecutorService,可用于在特定时间触发操作,但我想尝试actionListener 假设我创建了一个txt文件,并希望在一小时后将其删除。我如何通过actionListener做到这一点?有没有示例代码 我想写一个特定于时间的actionListener,它会触发一些 在特定时间采取行动。我知道有 java中的ScheduledExecutorService,可用于触发

我想写一个特定于时间的actionListener,它在特定时间触发一些动作。我知道java中有ScheduledExecutorService,可用于在特定时间触发操作,但我想尝试actionListener

假设我创建了一个txt文件,并希望在一小时后将其删除。我如何通过actionListener做到这一点?有没有示例代码

我想写一个特定于时间的actionListener,它会触发一些 在特定时间采取行动。我知道有 java中的ScheduledExecutorService,可用于触发操作 在某个特定的时间,但我想尝试actionListener

查看
Swing Timer
,来自定时器的事件应该是invoke
Swing Action
/
ActionListener

假设我创建了一个txt文件,并希望在一小时后将其删除。 我如何通过actionListener做到这一点?有没有示例代码

阅读Oracles教程,了解MCVE/SSCCE格式的工作代码示例

如何使用-

  • /

ActionListener对动作做出响应-您希望在稍后某个时间点执行某个动作。。。ActionListener与此没有任何直接关系(除了可能通过按下按钮启动流程外),ActionListener完全响应操作。触发特定时间也可能是一种行为。我没有使用任何swing或awt组件,比如按钮或任何东西。我不认为我需要寻找swing操作或swing计时器,因为我没有使用任何swing组件。我只想在特定的时间(文件创建后1小时)触发一个动作。@JavaDeveloper正如Nate在评论中告诉你的,
ActionListener
响应一个动作(即按下按钮,点击复选框,组合框等)。我也读过你对Nate的评论,
actionListener
是为
swing
设计的,所以你不需要
actionListener
。如果你想要一个更好的帮助,请用简单的词解释你想要什么,并提供一个例子(如果可能的话)。好的,如果ActionListeners是awt组件的专用工具,那么我可能不会使用它。最好使用ScheduledExecutorService。感谢您的帮助和解释。not ActionListeners在Java中打包在awt树中,这不是awt组件的详细信息