Results 1 to 2 of 2
  1. #1
    klmdb is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default have an eventlistener change values

    hi,

    I'm working through a little project to teach myself some java, but I've hit a wall here. I'll try to explain what I'm trying to do:

    I'm writing a simplified minesweeper. I use JButtons as squares with MouseListeners to process left/right-clicks.

    The problem is that I don't know how to make an EventListener return a value, or change a value in the main class that created the Listener.

    I know how to pass parameters to the EventListeners, but that doesn't help me solve this problem.

    any help would be appreciated,
    thx

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You would do well to search google (or check out wikipedia) for the MVC pattern. What you'd do is give your main class public methods to allow other classes to change its state, and then have your event listeners do just that.

Similar Threads

  1. ActionListener Error
    By blackstormattack in forum New To Java
    Replies: 1
    Last Post: 03-05-2009, 08:36 AM
  2. Replies: 3
    Last Post: 01-26-2009, 12:20 AM
  3. Java actionlistener help
    By justsomeguy in forum AWT / Swing
    Replies: 1
    Last Post: 05-27-2008, 05:42 AM
  4. Demonstrating the ActionListener
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 04-23-2008, 08:20 PM
  5. How to use KeyListener and ActionListener
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 04-23-2008, 08:19 PM

Posting Permissions

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