Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing Window Communication.

 
Kriss Reddy
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic