简体   繁体   English

获取IntelliJ来识别修改后的内部类方法

[英]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: 以下应该工作:

  • Go to the project settings File | Project Structure... 转到项目设置File | Project Structure... File | Project Structure...
  • Click on Modules in the left panel 单击左侧面板中的Modules
  • Select your module in the middle panel (the one called BotTutorial I assume) 在中间面板中选择您的模块(我假设该模块称为BotTutorial
  • Go to the Dependencies tab in the right panel 转到右侧面板中的“ Dependencies选项卡
  • Move <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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM