有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java中awt特定于时间的actionListener

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

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


共 (1) 个答案

  1. # 1 楼答案

    I want to write a time specific actionListener which triggers some action at a specific time. I know that there is ScheduledExecutorService in java which can be used to trigger a action at some specific time but I want to try actionListener.

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

    Let suppose I create a txt file and want to remove it after an hour. How can I do it by actionListener ? any example code ?

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

    如何使用-