"maya2000" <me*******@hotmail.com> wrote in message
news:29**************************@posting.google.c om...
Hi,
I am trying to open multiple Java3D windows from my application.
I want to open each window when I select a checkboxmenu.
Follwoing code doesn't show me the Java3D windows, so how can I make it
works? Thanks for your help.
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
while(openGLItem2.isSelected()) {
j3dWindow.createAndShowGUI();
}
}
});
}
Maya,
It seems you have not yet grasped the idea of event-based programming. The
createAndShowGUI() call probably creates the window and that is fine. You
should not add the loop after the creation. That is not how event-based
programs work. After creating the main window the main function has done its
task. The created window (and its subwindows, menus etc) should be decorated
with all kinds of listeners that tie application code to some event that is
caused by the user doing something with the gui. These listeners could
create new windows or do anything you like.
In that respect event-based programs are not like terminal applications
where you typically program one continuous flow that contains all the
programs behaviour. Think of event-based programs as a big state machine
where each ui action can result in a state-change.
Regards,
Silvio Bierman