How do i add the same mouselistener to many different instantiated objects?

This is for a card game.
The deck class instantiates 52 cards from the card class.
The game has a deck of cards. I am dealing each player their cards, the player is to be dealt 8 cards each of which should have a mouselistener.
How do I add the same mouselistener to each of the cards dealt.
This is how I have it so far but it only adds a mouselistener to the last card dealt.
     public void dealPlayerACard()
          taken = availableCards.dealCard();
          taken.showCard();
          taken.addMouseListener(this);
     public void mouseClicked(MouseEvent MEvent)
          playerHand.remove(taken);
          paintHand(playerHand);
          playerHand.repaint();
Any help would be appreciated

Yeh I have 52 card object in the deck. Theyre not individually named, they were instantiated in the deck class.
standardDeck.add(new Card(a, b, new ImageIcon(str), cardBack)); //creating and then adding the cards
So i draw one card at a time, and I had a mouselistener to that particular card. But the thing is, When the cards are clicked, some checking happens and if the move is legal, the card is added back into the deck and its mouselistener should be removed. This is because that card could then be added to the computers hand, and I dont want no player using the computer players cards.
The game deals the cards to players, players use the cards and then send them to the bottom of the deck, the deck is shuffled and then the game continues until a condition is met by either of the players.
So i dont understand how a loop solution would work here. My mind is blank at the moment, maybe im not understanding properly. I am new to java. So if you do know the answer, please tell it to me. Please dont wait for a lightbulb to appear above my head. ;)

Similar Messages

  • How do I add the same description to multiple photos in the new photos app

    How do I add the same description to multiple photos? I could do this in iPhoto but I do not see a way to do it in Photos for OS X. This is a handy feature to have.

    This link asks the same question,  https://discussions.apple.com/thread/6994338?searchText=How%20do%20I%20add%20a%2 0description%20to%20multiple%20photos?
    Someone shows the method to use AppleScript/ Automator to make Photos add the same description to multiple photos. I just opened up AppleScript editor and poked around the Dictionary for Photos and saw we have access to GPS longitude,latitude and altitude. So by using a third party app/web page to get those values, an Apple Script could be used to batch add the info to selected photos. That being said, I'm really busy these days and lack time to write scripts and migrate to photos.

  • How can I add the same transition to 200 photos?

    I'm making a slide show of over 200 photographs. How can I add the same transition between each photo without inserting it 200 times? There has to be a way to globally' insert transitions. What if I want to modify the length of the transitions or the photos? I don't want to modify each one individually.

    Daniel,
    Here are some references for you for applying a transition between all photos
    1)
    http://www.adobeforums.com/webx/.59b4ddb1/0
    will point you to a tutorial at muvipix.com
    Basically you do a Create Slideshow command choosing the transition before the photos are placed on the Premiere Elements Timeline. This process also specifies the duration for the "slide" and the transition.
    2)I suggest that you also read this FAQ about the resolution of photo files to be used in Premiere Elements. Even though written for an earlier version, it is still relevant (and potentially necessary) depending on the specs and status of your system
    http://www.adobeforums.com/webx/.3bb8822c

  • How can I add the same song more than once?

    how can I add the same song to my ipod shuffle more than once?

    Thanks. I tested it, and found that I can create a bookmark in FolderA, and them manually copy it to FolderB, FolderC, and FolderD.
    Once that is done, I tried the old method of "Bookmarks" --> "Bookmark This Page" and added it to FolderE. When I did that, it deleted the copy in FolderD but left the other three alone!
    This is fine with me. I personally think this is a bug, because I don't think that Firefox should ever delete a bookmark without asking me (or at least, informing me). But now that I understand the algorithm, I can work around it. Thanks!

  • How do i make the same song have two different genre

    how do i make the same song have 2 different genre for 2 different playlist?

    In my example, we will create a Smart Playlist that includes all songs in the genre Acid Jazz and one extra song that has the genre of Afro-beat. That extra song will be "Music For Gong Gong". To create your Smart Playlist, substitute the genre types and the song title (anything with <  > around it) for the ones you want.
    In your iTunes Library, either click on the + symbol in the lower left corner of iTunes playlists, or click CTRL+ALT+N to create a New Smart Playlist. The following will appear (my orange numbering):
    1. Using the drop-down menus, change "Artist" to Genre, "contains" to is and in the text box (marked 1) type in the text <Acid Jazz> (remember to chose the genre you want, and with the exact spelling used for that genre in your library - don't type in the <  > obviously!)
    2. Click on the + symbol at the end of that line (marked 2), which creates an additional line
    3. In this new line, change "Artist" to Grouping, change "contains" to is and in the text box type in <Acid Jazz> (Notice that I have used the same name as the genre itself. You don''t have to, but it makes it easier to add those extra songs. You'll understand why in step 7.) You now have a box like this:
    4. Change the Match rule at the top (notice it has already changed in the two screenshots above) to any. This is a crucial step, do not forget it.
    5. Notice that I have also selected Match only ticked items. This is optional, but selecting it will exclude songs that have been unticked. If you use Sync only ticked songs and videos, this can be useful way of keeping the Playlist the same as the one on your device.
    6. Click the OK button. You now have the opportunity to name your Playlist. I have chosen <Genre is Acid Jazz +> so that it is obvious what it is.
    So that's the Playlist created. As you can see, <Genre is Acid Jazz +> has 89 songs in it and I can assure you that's how many songs are in the Acid Jazz genre section. Now, all that remains is to add the additional song.
    7. Find your "two-genre" song and click File/Get Info/Info (or CTRL+I - that's an "eye") to bring up the edit song option. In the Grouping field, type in <Acid Jazz> (remember to use the same text you used in the Grouping box in step 3. This means you only have to type in the same genre name to the Grouping box,  to get it into that particular Playlist. I mentioned this in step 3).
    Notice that we are not changing the Genre. Click the OK button.
    Now look at the Playlist <Genre is Acid Jazz +> again.
    Notice that is now has 90 songs and at number 60 is the <Music For Gong Gong>. Note that the genre for that song is still Afro-beat, so the song still appears in the genre Afro-beat as well.
    To add any other song to this particular two-genre Playlist, simply find the song in your Library and type <Acid Jazz> into the Grouping box, as in step 7. It's that simple!
    Here's an extra tip. Too many Playlists and having issues finding your way through them?
    I have renamed the Playlist Genre is Acid Jazz + so that it is now named Acid Jazz Plus and I've dropped it into a Playlists Folder named GENRES (capitals makes it easy to find the folders on iDevices).
    Notice that here in iTunes, Playlists are sorted in the following order:
    Playlist Folders (and then the Smart Playlists and Regular Playlists inside it)
    Smart Playlists
    Regular Playlists
    ... but on my iPod Classic (for example), they are sorted in alphabetical order. So to find the Playlist Acid Jazz Plus, go into the Playlists menu and scroll down to G, go into GENRES, and in there will be Acid Jazz Plus, with all 90 songs!
    I hope you will give this a try, you have nothing to lose but a little time. Let us (all) know how you get on with it. We'd like to know.

  • How do i purchase the same song for a different itunes library on my computer?

    How do I purchase the same song for a different itunes library on the same computer?

    and then they will be sorted in the correct order.

  • Add the same component in 2 different tabs

    I am trying to add the same component in two different tabs in a tabbed pane. When I add it (programaticaly) the first instance disappears. Is this at all possible. I dont want to clone the component first and then add it.
    Thank you

    In my appllication I have a tab (call it main tab) that includes many components, like a textfield and texteditorpane that form a command line tool, a list of connected clients (names) and several other components in the same tab. Now the user, can issue a command from the command line to open any component in a new tab, for example he might want to open the clients list in a separate tab, while still having an instance of the clients list in the main tab.
    Also when something is updated (for example a new name is added in the list) I want both instances to be updated at the same time (since there is actually one Jlist object there shouldn't be any additional code to do that).
    So far, when i am opening a new tab holding a component from the command line (the one i made), the same component disappears from the main tab.
    I ll try what was mentioned above.
    Edited by: FreshPrince1 on Apr 12, 2010 6:50 AM

  • How do I add the same metadata to numerous files

    I do voice over work and need to add metadata to hundreds and hundreds of audio files. Some of the data is the same for ALL of the files.  Is there a way to autofill any of the meta data?  They all have the same artist, same genre, recording date, composer, technician, and copyright info. 

    Twice in a week:
    How do I apply the same info to specific metadata fields across multiple files, i.e. record date, artist, genre, composer, technician
    We'll add your notes to the feature request.

  • HT204053 How do I use the same Apple ID and different Cloud for other devises

    Hi
    How do I use the sane Apple ID and different Icloud for other devises

    http://support.apple.com/kb/HT4627

  • How can i use the same id on two different laptops?

    When trying to use the same login on two different laptops so that i can connect my nook to either depending on which one is free, i get the error that the id is already in use on another computer?

    The issue is embedded in the way the software works.  To comply with the
    Digital Millenium Copyright Act of 2000, all software companies in this
    business keep track of where their software is installed, making
    information about the computer and ereaders part of an ID file.  So, your
    user ID is embedded in the ID file of each computer, but each computer has
    a different ID of its own that is also embedded in that file.  Adobe's
    master server (yes, there is one that you connect to even if you didn't
    know it) also has that information, and when you try to use an ID on one
    that's embedded in the file of another, Adobe's server blows the whistle,
    and as you can see, you can't do that....
    ==========

  • How can I use the same event case for different controls dynamically

    OS: Linux 2.6.24-1-686 #1 SMP Sat Apr 19 00:37:55 UTC 2008 i686 GNU/Linux
    LabVIEW: Version 8.2
    I have a lot of (about 50) controls (numeric, boolean) on my front panel. If a "Value Change" event will be fired by any of them the same event case shall be executed. As I do not want to add all 50 controls to the same event case manually I am looking for a way to do it at run time. Additionally the VI is still under contruction, i.e. controls will be added and removed.
    Thanks for any help here.
    Regards,
    Johannes
    Solved!
    Go to Solution.

    Hi Johannes,
    collect all your control references (you can use the FP property for it) and create a user event. Connect this user event to your event structure. Now you have one event case for all your controls. See the attached picture.
    Mike
    Attachments:
    Unbenannt1.PNG ‏11 KB

  • How to work on the same catalogue with 2 different HDD's

    Hi,
    This must have been asked many times but I have no idea how to search for it because I don't think I can articulate my question well enough but I'll try it here.
    The case is that I have my laptop with LR4, I'm using an external HDD to store the RAW data from my camera. This HDD is fed by an external power line so it's not as portable (WD My Book3.5")
    So the setup is that LR4 is linked to the external HDD. Whenever I download photos from my CF card, I tell LR4 to copy the images to the external HDD because I don't want my laptop to be filled with RAW. I only export the JPG's to my laptop.
    Now here is the tricky part. When I travel, I take my laptop and my lighter external HDD (WD My passport 2.5") because it's portable and needs only USB power.
    While traveling I import my photos using LR4 to the secondary HDD (my passport) and I edit them. When I get back home, I would like to "merge" my edited images from the portable HDD (my passport) to the primary HDD (my book).
    So essentially I would like to streamline my work as if I'm managing one catalogue on two separate HDD.
    I hope I was clear about my question
    Is it possible?
    Thanks,
    Gil.

    How does the last paragraph differ from the second?
    The second paragraph describes how you would work while travelling, if you wanted to keep separate catalogs. The last paragraph describes what steps you would do when you returned.
    If I'm connecting both HDD's and while in LR4 I drag the folder from My Passport to My Book, I not only change the physical location of the RAW data, I also make LR4 keep my entire edit info and metadata changes so I can revert whenever I want, much as if I have always used the same HDD all along.
    Correct. The information that LR holds about a given image (including keywords, editing, etc) - is a completely separate consideration, than where the file is physically located. Changing LR's addressing of the image does not affect the image metadata, current edits, or the editing History.
    Whilst using the "import from catalog" I get the same result, isn't it? Or if I choose this option, LR4 essentially create a new catalog?
    Import from Catalog is used when you have already made a separate Catalog, and now want to merge (copy) its contents into the main one (and then delete the separate one).. It depends how you want to work.
    I think the 2nd paragraph provides the best solution to this scenario.
    It does have the adavantage that you can still see ALL of your pictures (at least, in Library). And while you are travelling, you can organise your new pictures into the same kinds of collections, keywords etc... those aspects can be immediately integrated (apart from the physical file locations, which in this scenario have to happen on your return).
    I would tend to take a copy of my main Catalog with me just for reference, but put the new images into a new separate one - a question of personal preference only. The end result is, as you say, the same.

  • How do I use the same bluetooth device with different iOS devices without having to "Forget" then "Pair" every time?

    Hi,
    I have bought a pair of Sennheiser MM100 wireless headphones and they are great, however, I'm having trouble switching between devices.
    I have an iPad2 and an iPhone 4s and the headphones connect to both with no problems. My issue comes when I want to switch from using the headphones with my iPhone (listening to music on the walk to the train station) to using them with my iPad (to watch a movie on the train). The iPad still shows that it is paired with the headphones but will not connect saying that they must be turned off or out of range. Even if I turn the headphones off then on again, they immediately reconnect with the iphone.
    I've tried deselecting the headphones as the source for audio from the airplay icon before I make the switch and have also done this before turning them off and then back on again.
    The only way I can make the switch is to turn the headphones off, tell the iPad to forget the device, turn the headphones on (by holding the on button for 5 seconds it automatically goes to Pair mode). I pair up the iPad and it connects fine. But I have to go through the same process when the train pulls into my stop to be able to use the headphones to listen to music to walk to work!
    Is there an easier way? I thought I would just be able to use the airplay icon to deselect it on one device and select it for the other.
    Any help would be much appreciated. I'm going to miss my stop on the train some day!!!

    Here's the trick.
    turn on the headphones.
    It will connect to the device it last connected to ...assuming that its' on.
    go to the bluetooth menu of your phone or ipad (if it's a computer you want to connect to I'll tell you that trick in a second.
    and so now, hold down the S button on the headphones for about 4 or 5 seconds (the same button you use to turn on the headphones) ...the light goes from blue to blinking red....now you're in the pairing mode...which is good...now in the bluetooth menu simply select the mm100 and it will connect...
    you won't have to type in the 0000 or tell it to forget the device..
    but by holding down the button and putting it in pairing mode it frees it from being connected to the device it automatically connected to and lets it connect to the device you choose. this is true of any bluetooth headset.
    if you want to connect to your computer, again...hold down that button on the headphones for 4 or 5 seconds till it enters pairing mode, then on your computer if you have a speaker icon in the menu bar, hold down the option key while selecting the speaker icon...you'll see a list of devices ...select the mm100 and your good to go.
    if you don't have the speaker icon there..go to system prefences and choose the mm100's there.

  • HT204053 How do I use the same email for two different apple IDs?

    I have inadvertently created two different Apple IDs throughout the years but now need my most recent one to use my email, but still want access to my old apple ID (if I can find it). The old apple ID has priority (the new one is not allowed to verify my email as it is linked to my old ID) with that email - can someone help me have the two IDs linked to the same email?
    Thank you

    AFAIK this is Not Possible. Each ID requires a Unique address
    Apple ID FAQs
    http://support.apple.com/kb/HE37

  • Is there a way to add the same description to many photos in iPhoto?

    I want to label a lot of photos with the same description [ie May '14 NY Trip]. Is there a way other than doing each individually?

    Use Batch Change.
    Select all photos at once.
    Then go to the Photos menu > Batch Change.
    Select "Set Description to Text" and enter the description.

Maybe you are looking for

  • Computers can't find each other with home sharing

    My home sharing has worked before but now I can't get my two computers to "see" each other. I have tried just about everything. Any helpful hints?

  • GR posting error

    Hi All, While doing Goods receipt i am facing the below error "Account Determination for entry 0A01 KDM 0001 ERN 5880 not possible " When i check the OBYC settings for KDM -5880 they have assigned 7 series GL account Where as in PO line item account

  • How do I install CS5 on a new computer. My old computer crashed.

    How do I install CS5 on a new computer. My old computer crashed.

  • From where we can get error log of delivering state

    Hi Experts,   I have processed large file and itseems the message got picked up successfully from sender side and got stucked in deleivering state. Can anyone suggest from where can we get error log that why the message is in delivering state. I have

  • Problem with supplied OS X install discs

    hey everyone- after reading around on here, I found out that using Migration Assistant to transfer the files from my G4 were possibly hurting my performance. I'd also read that the preferred course of action in this case was to archive and install. w