wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Interface implementation syntax sugar with SWT ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interface implementation syntax sugar with SWT ?" Watch "Interface implementation syntax sugar with SWT ?" New topic

Interface implementation syntax sugar with SWT ?

Senhor Ignoradoo

Joined: Jun 11, 2009
Posts: 2
Hi, i have this snippet from SWT:

I understad all the code, except:

Looks like it´s implementing an interface ? Can somebody provide me an explanation or a link to some book that explains that ?

Thanks in advance.

Sr Ignorado
Jason Irwin
Ranch Hand

Joined: Jun 09, 2009
Posts: 327
It's creating a Listener instance and using an in-line declaration to override the "handleEvent" method, that's what seems to contain the logic for the toggle button -> radio button behavioural change mentions in the comment header.


Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3816

That's an anonymous inner class example. That's probably the only place you will apply "new" keyword to the name of an interface. That's how you create an object of a class which implements an interface. The class implementing the interface becomes anonymous here as you have a reference of type interface to an object of that class. Nested classes from SUN tutorials gives you a brief explanation.

[How to ask questions] [Twitter]
Senhor Ignoradoo

Joined: Jun 11, 2009
Posts: 2
Thanks. I got now :-).
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

Sr Ignorado, please check your private messages for an administrative matter.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
I agree. Here's the link: http://aspose.com/file-tools
subject: Interface implementation syntax sugar with SWT ?
Similar Threads
Swing + SWT
Exception in thread "AWT-EventQueue-0" org.eclipse.swt.SWTException: Invalid thread access
Shell keeps popping up when creating a menu tray
Sample code to drag drop buttons in Applet
Problem creating a dynamic form with SWT