Passing Data From JFrame to JFrame Or to JDialog

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sibusiso
    New Member
    • Aug 2008
    • 18

    Passing Data From JFrame to JFrame Or to JDialog

    HI

    Can anyone help with the scenario where where you have to pass a certain data from one JFrame to another.

    For example, suppose you have a JFrame is your main window you disabled your Jmenu and have an option of Login button and the login button calls another JDialog Class, say if Login() is true in Jdialog then enable JMenu on JFrame(Main window) exit the JDialog class.
    I am using NetBeans.

    Because I want to control the menu according to the Login status if is Administrator or not.
    Last edited by sibusiso; Nov 26 '08, 10:04 AM. Reason: Add some text
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Do it the other way around: create a singleton Administrator object with a method (for convenience): public boolean isAdministrator (). Also create the methods login() and logout() and most important: create an addListener() method that can be used to register objects that are interested in the status change of the Administrator object (see the PropertyChangeS upport class for details).

    Any objects interested in the login status of the Adminstrator register themself at that object and change their state accordingly when they receive an event. A bit of work setting it all up but it certainly pays back.

    kind regards,

    Jos

    Comment

    Working...