• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swing Window Communication.

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Friends help you move. Good friends help you move bodies. This tiny ad will help:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic