Search code examples
javamethodsintellij-ideainspections

Why would IntelliJ IDEA (12.1.6) not be able to resolve BorderFactory.createLineBorder(...)?


Why would IntelliJ IDEA (12.1.6) be unable to resolve the createLineBorder() method from BorderFactory?

Here are some screenshots to illustrate the issue:

Here, you can see as I type in the method name, IDEA recognizes it as a valid option for autocomplete. enter image description here

So, I am fairly certain it is resolving the method. But then this: enter image description here

First, I thought maybe an intention action would help me correct the issue, but pressing Alt+Enter doesn't help much either: enter image description here

So, I did some searching through SO, and found this: IntellJ IDEA "cannot resolve symbol" and "cannot resolve method"

I invalidated the caches, then restarted IDEA. When that did not work, I removed the SDK from the project and then re-added it per CrazyCoder's instructions. No dice.

You can see in the images, that it was easy to work around. My problem is what could be preventing IntelliJ from resolving a method that it, on some level (auto complete), has already resolved. The code that is causing problems follows the example of how to create a line border in the Java tutorials. Any ideas would be great.


Solution

  • BorderFactory.createLineBorder(Color color) is a static method, get rid of new and the method will be resolved.

    Reference: BorderFactory.createLineBorder(java.awt.Color)