By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

How to run another sub-Main() in an application?

P: n/a
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();
}
}
});
}
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"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
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.