This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Thomas Peter wrote:... thanks but I guess that's not what I'm looking for ;-)
...I want a method that doesnt check just one hardcoded class like...
...but a variable class..
In that case check out Class#isInstance(Object obj)
You need something like (typed here, may have typos or other bugs -- read the API for Class#isAssignableFrom)Note that class is a keyword. You can't use it as a variable or parameter identifier.
edit Oops, was I really on the phonefor so long? isInstance is a better choice. Also, I got isAssignableFrom backwards should have been clazz.isAssignableFrom(co.getClass())
luck, db
There are no new questions, but there may be new answers.
So, I'll ask what nobody else has: why do you want to do this? One of the advantages of OOP is that we really shouldn't need to do this kind of operation.
Thomas Peter
Greenhorn
Joined: Oct 02, 2010
Posts: 4
posted
0
;-)
I almost expected that question. My problem is having programmed a long time in VB and now I want to learn how the things can be done in Java.
Explicitly I tried to change one JButtons label from another method. Or try to access a component directly by its name ...