Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Unable to Reuse Object (JAVA)

  1. #11
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    1,837
    Distro
    Kubuntu 12.10 Quantal Quetzal

    Re: Unable to Reuse Object (JAVA)

    Quote Originally Posted by kevinharper View Post
    I guess I should explain where I think the problem I'm having comes from...

    Program starts with a CardLayout that switches through 3 panels (login, login error, login success).

    Login success panel, in turn, contains another cardlayout (among other objects). So when the program starts, ALL of this is loaded at once. And because User doesn't get set until the user logs in, all JPanels testing the user's accessLevel get null values.

    I'm guessing there is a way to not load "cards" until an event happens.
    You have to change your design to load the panels only once you know what they should contain based on user authentication data... or the panels can interpret unspecified values as "don't know, be ready for a change later" (for instance go invisible)

  2. #12
    Join Date
    May 2011
    Beans
    253
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Unable to Reuse Object (JAVA)

    Done. It's a hack and I know it. But it works.

    My LoginPanel controls what card to show in my CardLayoutPanel. I took the add & show statements out of the main class in CardLayoutpanel and placed in inside the public method that received LoginPanel String that controls viewed card.

    A simple "if" stringReceived whatever.equal("success"), add successPanel to CardLayoutPanel and show it. WORKS EXACTLY LIKE I WANT IT TO! AWESOME!

    Once again, thank you for your responses and for your help guys.
    Kevin Harper
    http://www.kevinharper.com/


    Ubuntu: Because rebooting is ONLY for installing hardware

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •