你可以调用 Component.setName 方法,或者使用 JComponent.putClientProperty 方法,或者继承或使用 JLabel 对象作为某种 Map 的键来操作它。 但最好的方法可能是保留对原始对象的引用,这样你就可以编写干净、直接的代码,而不必查找组件。