Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Use javax.swing.Action instead?

 
Ranch Foreman
Posts: 1907
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I just come across javax.swing.Action. It extends ActionListener in java.awt.
For the exam, should I use Action intead of ActionListener?
In study guide, the example code uses ActionListener too.
But the exam requires Swing component.

Which one should I use then? Action or ActionListener?
Thanks in advance.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Himai Minh wrote:Which one should I use then? Action or ActionListener?



Well, you can use whichever you prefer. You just can't use classes of the java.awt package that have corresponding ones in the java.swing package. For instance, you can't use java.awt.Button, since there's javax.swing.JButton. But there's no problem in using java.awt.event.ActionListener.

Either Action or ActionListener are fine.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(As always) I agree with my good buddy Roberto.
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Damn Roberto beat me to the reply

Yes Roberto is right, either one is fine. Action is a class, need to extend AbstractAction. ActionListener is an interface, implements it. Yet whatever you choose, be consistent.

 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic