0

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.

Community
  • 1
  • 1
nihilon
  • 834
  • 2
  • 8
  • 23

1 Answers1

4

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

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

kukido
  • 10,431
  • 1
  • 45
  • 52
  • So. Did I mention I am very new at this? Thanks for the answer, and a quick one at that. – nihilon Jan 08 '14 at 07:45
  • 1
    NP :-) IntelliJ tried to warn you about that from the beginning. Look at the first image, BorderFactory is underlined, because there's no constructor. So then you tried to "instantiate" (from the IntelliJ point of view) inner class BorderFactory.createLineColor(), which was not found :-) – kukido Jan 08 '14 at 07:50