• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

why is the actionEvent greyed out

bnStart.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                doStart();                                           ^
                                                                           ^  this is greyed out, does that eman i'm not using it?
0
pigmentarts
Asked:
pigmentarts
  • 9
  • 4
  • 3
  • +2
1 Solution
 
objectsCommented:
sounds like a reasonable assumption.
0
 
zzynxSoftware engineerCommented:
bnStart.setEnabled(true);
0
 
zzynxSoftware engineerCommented:
greyed out? Where? In your editor?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
CEHJCommented:
That would depend on your IDE. If it compiles, yes, possibly. If it doesn't, maybe it's not imported
0
 
zzynxSoftware engineerCommented:
What editor/IDE do you use?
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> If it doesn't, maybe it's not imported

If new ActionListener () complies (means it is imported), then so should ActionEvent.... are you using Netbeans?
0
 
CEHJCommented:
>>If new ActionListener () complies (means it is imported), then so should ActionEvent

Why so?
0
 
zzynxSoftware engineerCommented:
mayank probably means that if you have

import java.awt.event.*;  

both ActionListener and ActionEvent are known

But mayank, you could of course have

import java.awt.event.ActionListener;
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Because they are in the same package? Unless he imported java.awt.event.ActionListener instead of event.* .... :)

Anyway, most IDEs still recognize the classes and show a colour regardless of whether it was imported or not (of course, on compiling you would know the error).... ;)
0
 
CEHJCommented:
>>Unless he imported java.awt.event.ActionListener instead of event.* .... :)

Most decent IDEs will encourage precisely that good practice ( as opposed to import x.* )  ;-)
0
 
zzynxSoftware engineerCommented:
CEHJ, I'm interested in the reason why it would be good/better practice to have

import java.awt.event.ActionListener;

instead of

import java.awt.event.*;
0
 
CEHJCommented:
Because it announces precisely what classes are being used (unless a declaration is redundant [a good ide will warn about that too]) which is useful for maintenance
0
 
zzynxSoftware engineerCommented:
Mmmm. That's the argument I always hear.
But so far, I don't experience any (maintenance)problems with using *
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Good point. Personally, I use import java.awt.event.* to reduce the number of import-lines (for some reason, if there are many import lines, it doesn't look good to me and I get anxious to see where the real code of the class starts ;-)). If there are any classes with the same name and in multiple packages (like java.util.Date and java.sql.Date), then I use the full package-name in the code. Luckily - my company's coding-standard does not have a problem with that and does not enforce me to use import java.awt.event.ActionListener instead of * (phew~!) :-)

Does it have any advantage on the compile-time though?
0
 
zzynxSoftware engineerCommented:
I feel excatly like you mayank.

>> Does it have any advantage on the compile-time though?
No afaik.
0
 
pigmentartsAuthor Commented:
I'm back, thx for all your comments.

The only reason I've been using import java.awt.event.ActionListener instead of * is to help in the initial learning.
Just to help me build up the method of using java.
0
 
pigmentartsAuthor Commented:
>>bnStart.setEnabled(true);

do I need to do this for the action to work? I don't think i do so whats it for?
0
 
zzynxSoftware engineerCommented:
Any questions left?
0
 
zzynxSoftware engineerCommented:
>> whats it for?
Forget that. I first thought you meant that the button the action was linked to was greyed out.
0
 
objectsCommented:
> do I need to do this for the action to work? I don't think i do so whats it for?

no
0
 
pigmentartsAuthor Commented:
>>sounds like a reasonable assumption

but surley i am using it if the start button works d8-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 9
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now