Results 1 to 4 of 4
  1. #1
    chillin is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Lightbulb HashMaps containing JComponents

    Hey all,

    I've got a 2D HashMap, in which there are JCheckBoxes, JButtons, and JTextFields, so it's like: HashMap <String, HashMap<String, JComponent>>. I add JComponents dynamically to it. My goal is to add some listener to the JComponents, which is able to indicate either the user clicked on the button, or checked the checkbox, and to be able to get to know the key which belongs to the chosen JComponent.
    Can anyone help me? I'd appreciate your help.

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

  3. #3
    chillin is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default

    Thank you for your answer. I'm sorry if I wasn't exact enough. My question is: which listener should I add to my Hashmap/JComponent to reach my goal? Since I handle my CheckBoxes, ect. together, I can't use ItemListener, or any other specific listeners.
    It's important to get to know what happened, and which key belongs to the JComponent which sent the event.

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

    Default

    I'm not sure why you're using this design and what you're trying to achieve from it, but perhaps there is another and better way to achieve your end goals. Please give us more information on the problem you're trying to solve from the user's perspective and not from a specific code solution perspective.

Similar Threads

  1. hashmaps
    By santa in forum New To Java
    Replies: 6
    Last Post: 05-04-2011, 12:07 AM
  2. JComponents Are Wrong Size
    By MrFish in forum AWT / Swing
    Replies: 2
    Last Post: 12-21-2010, 04:13 AM
  3. Concerning HashMaps
    By hjensen in forum New To Java
    Replies: 7
    Last Post: 10-18-2010, 04:36 PM
  4. Problems with HashMaps
    By li_bi in forum New To Java
    Replies: 13
    Last Post: 02-24-2010, 01:08 PM
  5. HashMaps get key for a specific value
    By andre1011 in forum Advanced Java
    Replies: 2
    Last Post: 03-11-2009, 03:30 AM

Tags for this Thread

Posting Permissions

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