Can someone help me in connecing the windows using java...?

I am doing a project in virtual class..So i need to link the windows.

Please help...

Thanking u all in advance.

Regards,
Shreya.

Dani AI

Generated

Following 's clarification, the core choices are how tightly coupled your windows are and which UI strategy you use. and pointed toward direct wiring between windows; a more scalable approach is to separate navigation from view logic so buttons ask a controller or event hub to switch views, not call other windows' internals.

A simple, practical pattern for Swing is a single top-level frame that swaps view panels (CardLayout) or uses JInternalFrame inside a JDesktopPane for MDI. Each view should expose only callbacks (listeners/interfaces) and fire navigation events to a controller. Example of switching with CardLayout:

JPanel cards = new JPanel(new CardLayout());
cards.add(new LoginPanel(), "login");
cards.add(newClassroomPanel(), "classroom");

CardLayout cl = (CardLayout) cards.getLayout();
cl.show(cards, "classroom");

Keep views thin: put shared state (session, user, resources) in a model object that the controller and views can read. Use listener removal and call dispose() on frames you no longer need to avoid leaks. Always update Swing UI on the Event Dispatch Thread (SwingUtilities.invokeLater) and avoid multiple visible JFrames (focus and modality issues). If using JavaFX instead, swap Scenes or use a single Stage.

For more detail on Swing layouts and best practices see the Oracle Swing tutorial: Swing tutorial.

Recommended Answers

All 4 Replies

What does "linking" or "connecting" windows mean?
Do you want each class that has opened a window to have a reference to the other classes that have opened a window?

or you mean by connecting windows that you are using GUI and needs to connect one frame with another ?

Yes, actually i mean each class that has opened a window to have a reference to the other classes that have opened another window...so that when we click a button in one class then it takes us to other class features in other window...
I hope I m making my point clear...

If not please tell me...

Thank you..:)

If all these classes are executing in the same JVM, then when you create a new instance of a class with a window, pass it a reference to the other classes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.