[英]Get IntelliJ to recognize modified internal class method
In NetBeans I created a class: java.awt.Canvas (I use -XBootClassPath). 在NetBeans中,我创建了一个类:java.awt.Canvas(我使用-XBootClassPath)。 In this class, I add a function call: "addPaintListener".
在此类中,我添加了一个函数调用:“ addPaintListener”。
When I compile, it works fine. 当我编译时,它工作正常。 I can write code like (In netbeans. No errors):
我可以编写如下代码(在netbeans中。没有错误):
public static void notifyCanvasReady(Canvas canvas) {
canvas.addPaintListener((PaintListener) g -> {
g.setColor(Color.white);
g.drawString("HELLO WORLD", 50, 50);
});
}
But in IntelliJ, it gives me an error: 但是在IntelliJ中,它给了我一个错误:
However, if I Right-Click the project and hit compile module, it compiles fine (still shows the error) but actually runs regardless. 但是,如果我右键单击该项目并点击编译模块,它可以正常编译(仍然显示错误),但是无论如何都可以运行。
Any idea how I can get it to stop showing the error or get it to recognize my modified internal class? 知道如何使它停止显示错误或使其识别修改后的内部类吗?
The comments are right that you are not supposed to modify JDK classes, if you are not a JDK engineer. 如果您不是JDK工程师,那么您不应该修改JDK类的注释是正确的。 However let's assume you really want to do this.
但是,假设您确实要执行此操作。 The following should work:
以下应该工作:
File | Project Structure...
File | Project Structure...
File | Project Structure...
Modules
in the left panel Modules
Dependencies
tab in the right panel Dependencies
选项卡 <Module source>
up above the JDK in the table using drag&drop or the arrow buttons at the bottom. <Module source>
向上移动到表中JDK的上方。 Here's what the dialog looks like. 这是对话框的外观。
<Module source>
should be at the top of the table, above the 1.7_15
JDK. <Module source>
应该位于表格的顶部,在1.7_15
JDK之上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.