| Author |
What does this do? What is it's name?
|
Jerry Kilpatrick
Greenhorn
Joined: Jan 02, 2005
Posts: 6
|
|
I came across the following code in one of the examples for the Swing Tutorial. I am not familiar with this syntax. What does it do? What is it's name? Thanks, Jerry
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Originally posted by Jerry Kilpatrick: ... I am not familiar with this syntax. What does it do? What is it's name? ...
I'm guessing that the syntax you're referring to is the anonymous class definition. Basically, an anonymous class looks like a constructor call, but before the closing semicolon, a class definition is slipped in with braces. The result is a class that implicitly extends the class (or implements the interface) identified after the keyword "new." Furthermore, the instance of this anonymous class is automatically upcast to the type it extends (or implements). In this particular case, we have an anonymous class that extends JLabel, and the new instance is upcast to type JLabel. [ November 30, 2005: Message edited by: marc weber ]
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Jerry Kilpatrick
Greenhorn
Joined: Jan 02, 2005
Posts: 6
|
|
Marc, Exactly the answer I was looking for. Thanks, Jerry
|
 |
 |
|
|
subject: What does this do? What is it's name?
|
|
|