【发布时间】:2020-12-04 13:31:05
【问题描述】:
我有一个鼠标侦听器,当我在应用程序窗口中移动鼠标时会调用它。 在 MouseEntered 方法中,我这样调用 ThreadB:
@Override
public synchronized void mouseEntered(MouseEvent e) {
..
ThreadB b = new ThreadB();
b.start();
System.out.println("Before Sync!!!!!!!");
synchronized(b) {
try{
System.out.println("Waiting for b to complete...");
b.wait();
}catch(InterruptedException ex){
ex.printStackTrace();
}
}
System.out.println("After Sync!!!!!!!");
}
class ThreadB extends Thread {
@Override
public void run(){
synchronized(this){
int dialogResult = JOptionPane.showConfirmDialog(null, "Loading process is in progress. Do you want to stop the process?", "Loading Accounts", JOptionPane.YES_NO_OPTION);
if (dialogResult == 0) {
System.out.println("Yes is chosen!!!!");
}else {
System.out.println("No is chosen!!!!");
}
System.out.println("before NOTIFY!!!!!!!");
notify();
}
}
}
加载过程按预期停止,但对话框没有被绘制,这意味着它不显示其组件。
非常感谢您的帮助。
非常感谢
问候
【问题讨论】:
标签: java swing user-interface components jdialog