gpt4 book ai didi

java - 如何向我的 JTable 添加延迟?

转载 作者:行者123 更新时间:2023-11-30 08:14:18 25 4
gpt4 key购买 nike

每次添加行时,我的 JTable 都需要延迟。

public void añadirNuevo(Procesos procesosArray){
for(int i=0;i<procesosArray.size();i++){
Object nuevo[]= {procesosArray.obtener(i).getNombre(),procesosArray.obtener(i).getTam()};
nuevoTbl.addRow(nuevo);
//DELAY
}
}

最佳答案

使用javax.swing.Timer

Setting up a timer involves creating a Timer object, registering one or more action listeners on it, and starting the timer using the start method. For example, the following code creates and starts a timer that fires an action event once per second (as specified by the first argument to the Timer constructor). The second argument to the Timer constructor specifies a listener to receive the timer's action events.

int delay = 1000; //milliseconds   
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//...Perform a task...
}
};
new Timer(delay, taskPerformer).start();

关于java - 如何向我的 JTable 添加延迟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29878619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com