Villager
Villager

Reputation: 89

How can I set the start-up project?

I've got multiple JFrames and each of them has a 'main'. The one that opens when I click 'Run' is the first JFrame I created. How can I change it so that a different JFrame I made opens up?

Upvotes: 0

Views: 50

Answers (1)

MightyPork
MightyPork

Reputation: 18861

You shouldn't have more public static void main(String[] argv) methods in your application, and as a matter of fact, only one JFrame is typically used. The others are done with JDialog, which does some nice things for you, such as disabling the main window when active.

The main method creates the main frame, and others are then opened based on some events in this frame.

You open a dialog window (MyDialog extends JDialog) somewhat like this:

JDialog dlg = new MyDialog(mainFrame);
dlg.setVisible(true);

Upvotes: 1

Related Questions