my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Swing Window Communication. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing Window Communication." Watch "Swing Window Communication." New topic
Author

Swing Window Communication.

Kriss Reddy
Ranch Hand

Joined: Mar 29, 2005
Posts: 54
Hello,

I am new to Swing and would like to know how different swing components communicate with each other. What I mean by components could be anything like dialog, panel, frame etc. How a dialog talks to a frame and how a frame talks to a panel etc.

I am using net beans gui builder to get a quick start, and I made an app using JFrame which works fine - added a file chooser and text box which sets the value of text box to the item selected in filechooser, pretty basic.

Now I want to add (not sure what is right here) a login window so that when I launch this application I need my log in window to appear first, authenticate -pretty simple string comparison is good, then my app in the JFrame created.

Thanks for all your help.
Kriss.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I am new to Swing and would like to know how different swing components communicate with each other.

Swing is event-driven
Components listen for events via listeners, and react according to their instruction

in a simple login-screen, the user types in username/password, clicks 'login' (the clicking of the button is an event)
the listener - actionListener (generally), compares the username/password to the db, and if successful,
disposes the login screen then displays the application JFrame (or can return a boolean to the main application)

google
java swing login

you should find plenty of sample code
Kriss Reddy
Ranch Hand

Joined: Mar 29, 2005
Posts: 54
Thanks Michael. I have a login dialog now.

Another question,

I have a JTree on a frame and I want to initialize and populate that tree only after click of a button. How should I implement this?

Thanks,
Kriss.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing Window Communication.
 
Similar Threads
JVM crash
Parent Frames and Panel
Dialogs windows not displaying properly
JFrame size and location problems
How to display alert box at the top of all frames ?