Converting from Object to Button

I have code like this:
public void mouseClicked(java.awt.event.MouseEvent event)
{
      Object object = event.getSource();
      if (object == cmdPlay0 ||
            object == cmdPlay1 ||
            object == cmdPlay2 ||
            object == cmdPlay3 ||
            object == cmdPlay4 ||
            object == cmdPlay5 ||
            object == cmdPlay6 ||
            object == cmdPlay7 ||
            object == cmdPlay8)
            cmdPlay_MouseClicked(event, object);
}

Passing the object to cmdPlay_MouseClicked.  In the procedure cmdPlay_MouseClicked, I want to reference the specific button clicked.  Something like this:
void cmdPlay_MouseClicked(java.awt.event.MouseEvent event, Object objTarget)
{
      Button btnTarget = objTarget;
      if (btnTarget.getLabel() != "X") {
            btnTarget.setLabel("X");
      }
                  
}

The problem is that it doesn't want to convert objTarget to btnTarget.

How do I do this?
LVL 6
clifABBAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mattropeCommented:
Try casting objTarget into an object of type Button like this:

Button btnTarget = (Button)objTarget;

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
clifABBAuthor Commented:
That's it!
I knew there was a way to do this, but I could find nothing about it in the tutorials I had read.

Thanks a lot.

An extra 25 for such a quick answer.
0
clifABBAuthor Commented:
mattrope:
I increased the points to 75, but I don't think it registered.  If not, let me know and I'll post an additional question.
0
mattropeCommented:
I don't think it did register--it doesn't show in the question history.
0
clifABBAuthor Commented:
mattrope:
I posted another question with the extra 25 points for your super quick answer:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=10236913 

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.