| Author |
Use javax.swing.Action instead?
|
Himai Minh
Ranch Hand
Joined: Jul 29, 2012
Posts: 292
|
|
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.
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
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.
|
Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4352
|
|
|
(As always) I agree with my good buddy Roberto.
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
K. Tsang
Ranch Hand
Joined: Sep 13, 2007
Posts: 1222
|
|
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.
|
K. Tsang JavaRanch SCJP5 SCJD/OCM-JD
|
 |
 |
|
|
subject: Use javax.swing.Action instead?
|
|
|