There's a nice discussion on EventQueue.invokeLater() here.
I have a controller class, Master()
that loads two UI windows in my application. For example:
public class Master(){
public Master(){
aView = new subView();
bView = new subView();
Where subView
extends JFrame and has the following main method:
public class SubView extends JFrame{
....
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new SubView();
}
});}
}
Notice that SubView.main()
uses the invokeLater()
. My question is how can I invokeLater() within master? Something like:
public class Master(){
public Master(){
aView = EventQueue.invokeLater(new subView);
bView = EventQueue.invokeLater(new subView);
It's not this simple because invokeLater does not return anything. Furthermore, because it's "invoked later", the values of aView and bView remain null in Master. Is there anyway to invoke both in the same manner that main()
would invoke one of them in the runLater thread?