Java的按钮监听器实现多线程处理(边运行程序 边显示提示信息)
xiaozhun.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente...
xiaozhun.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
EyeOne i1 = EyeOne.getInstance();
if(!i1.isConnected()) {
cwxx.setText("Device is not connected...");
System.out.println("Device not connected. Please connect device before trying again");
return;
}
cwxx.setText(a+"Device is connected...");
这是监听器的一段代码 情况是 按下按钮之后 我这边!i1.isConnected()等等在判断运行,
而settest因为没有设置多线程,所以没反应cwxx.setText("Device is not connected...");
要直到程序结束后才有反应,谁能告诉我针对这段代码的多线程如何写,让他能顺利边
run 边输出。请给具体一点的代码 谢谢。 展开
public void actionPerformed(ActionEvent e) {
try {
EyeOne i1 = EyeOne.getInstance();
if(!i1.isConnected()) {
cwxx.setText("Device is not connected...");
System.out.println("Device not connected. Please connect device before trying again");
return;
}
cwxx.setText(a+"Device is connected...");
这是监听器的一段代码 情况是 按下按钮之后 我这边!i1.isConnected()等等在判断运行,
而settest因为没有设置多线程,所以没反应cwxx.setText("Device is not connected...");
要直到程序结束后才有反应,谁能告诉我针对这段代码的多线程如何写,让他能顺利边
run 边输出。请给具体一点的代码 谢谢。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询