The IDEA lightbulb icon appears in the IDEA editor when the IDE detects a probable bug, design deficiency, or necessary addition to the code. These are called “intention actions”. At its best it works like magic to speed the developer’s work, relieving the tedium of writing boilerplate code to meet Java’s sometimes verbose requirements. The strength of IDEA’s opinion is suggested by the icon, with a red exclamation mark indicating a defect that will generally not compile. This is a useful feature, though at times it seems as if IDEA will generate a lightbulb for almost any line of code, making it hard to know when it is worth checking out the suggestion. This can be adjusted by disabling unwanted “intentions”.
The code which IDEA generates is generally determined by templates, all of which are available to edit. In fact, the editor will sometimes display a lightbulb, giving one-click access to the template it has just used.