为什么导入 javax.swing.* 而不是 java.swing.*

2022-01-13 00:00:00 package java swing

我不明白为什么少数导入包的java"后面会附加x".是什么原因?不能像其他java.io.*一样只是java.swing.*吗?

I did not understand why there is "x" appended to "java" for few of the import packages. What is the reason? Can't it be just java.swing.* like others java.io.*?

推荐答案

Swing 最初是对 Java 的扩展 - 一个可单独下载的库.它成为 Java 1.2 中主要"JRE 的一部分.一个单独的库声称一个 java.* 包是很奇怪的,因此是目前的情况.还有很多其他扩展都有类似的故事.

Swing was originally an extension to Java - a separately downloadable library. It became part of the "main" JRE in Java 1.2. It would have been odd for a separate library to have claimed a java.* package, hence the current situation. There are plenty of other extensions which have a similar story.

维基百科关于 Swing 的文章 提供了有关其历史的更多信息.

The Wikipedia article on Swing has a bit more information on its history.

相关文章