Results 1 to 3 of 3
  1. #1
    adamnoakes is offline Member
    Join Date
    Feb 2014
    Posts
    2
    Rep Power
    0

    Default Passing boolean by reference to event listener

    Hi,
    Is there a way to pass a boolean from my GUI class to my event listener classes so that i can use check boxes to control booleans that exist in the main class?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,036
    Rep Power
    6

    Default Re: Passing boolean by reference to event listener

    Nope. At least not via the event itself. You may add any other method to your event class such as a set method to set an instance field. However, if you use inner classes, then the inner class has access to all of the outer class' instance fields. Also, the event listeners should provide you access to the source of the event. You may then cast that source to the actual class that generated the event and then do with it what you need to. Just don't take too long doing it.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    adamnoakes is offline Member
    Join Date
    Feb 2014
    Posts
    2
    Rep Power
    0

    Default Re: Passing boolean by reference to event listener

    Ok thank you i think i am going to use inner classes to solve the problem.

Similar Threads

  1. Passing variables by Value or Reference
    By Peter Peterson in forum New To Java
    Replies: 9
    Last Post: 12-26-2013, 02:18 PM
  2. Question on Passing by Reference..
    By fatabass in forum New To Java
    Replies: 1
    Last Post: 02-07-2012, 01:02 AM
  3. get onbjet reference on mouse event
    By spimees in forum AWT / Swing
    Replies: 2
    Last Post: 05-18-2011, 06:28 AM
  4. Passing Class Reference to method
    By nekt in forum Advanced Java
    Replies: 5
    Last Post: 03-26-2009, 06:08 AM
  5. Listener for SWT event
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 10:04 AM

Posting Permissions

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