[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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