【问题标题】:Cannot import JFrame or Dimension无法导入 JFrame 或 Dimension
【发布时间】:2020-05-06 17:44:35
【问题描述】:

我的包中已经有系统库,并尝试重置元数据。我还能做什么?

cmets 的错误说明它们是什么错误。

package JFrameTest;

import java.awt.Dimension; //The package java.awt is not accessible
import javax.swing.JFrame; //The type javax.swing.JFrame is not accessible

public class Empty extends JFrame { //JFrame cannot be resolved to a type

    public static void main (String[] args) {
        new Main().setVisible(true);  // Main cannot be resolved to a type
}

【问题讨论】:

  • 第一个结束 } 丢失,new Empty() i.o. new Main()。包/文件夹名称通常是小写字母。他们必须匹配。使用 IDE 来防止路径问题。
  • 修复了最后两 (3) 个错误,并且没有错误,但那是在另一台计算机上

标签: java swing import compiler-errors jframe


【解决方案1】:

JavaFX 已从 JDK 中删除,因此您需要从 herehere 下载 JavaFX 或使用 this 指南。如果您使用 maven,只需添加依赖项即可。

【讨论】:

  • 这是 swing,不是 JavaFX。 ;)
猜你喜欢
  • 2017-01-28
  • 2020-11-20
  • 2019-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-13
相关资源
最近更新 更多