Runnable r = new Runnable() {
@Override
public void run() {
if(varx) {
new displayFullScreen().setVisible(true);
} else {
javax.swing.JOptionPane.showMessageDialog(this, "dfv"); // this statement gives an error
}
}
};
new Thread(r,"full_screen_display").start();
The error in the marked line says "No suitable method found for anonymous (<java.lang.Runnable>,java.lang.String)“
Why does it so when i have directly written javax.swing._CLASS_ ?
The problem is that
thisin that line refers to the anonymousRunnableinstance you’ve created, not the class that surrounds it. You’ll need to be more explicit about whatthisyou mean in there.If the enclosing class is named
Foo, and is a swingComponent, you should write:See the Nested Classes docs for more information.