How to access different JFrame
executing in different event dispatch threads of a Java application Please go through the SSCCE posed here
Will new instance of JVM or reflection help in this case
In the end as I mentioned If the following code is added to the first class
Frame[] f2 = JFrame.getFrames();
for(Frame fx: f2){
System.out.println(fx.getTitle());
fx.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
}
only a single frame is returned if added to second class in sequence in SSCCE two frames are returned and if added to third class All frames are returned. Is this a problem due to event dispatch threads what is the reason behind this behavior. How to access all frames from Main frame i.e., MyApp.
Why does JFrame.getFrames(); returns awt Frames say for example if I want to change the default close operation of all JFrames in my application gerFrames returns awt frames which if caset in JFrame produces an exception.
Exception in thread "main" java.lang.ClassCastException: [Ljava.awt.Frame; cannot be cast to [Ljavax.swing.JFrame; at myApp.MYApp.main(MYApp.java:48)