Java class 尽管有新...;没有被召唤

Java class is despite new ...; not called up

我无法调用 class。我在 Eclipse 中编程,我有另一个 Java 程序,它工作得很好,但我看不出有什么区别。这是 Main class:

的代码
public class Main {
        public static void main(String[] args) {
                new Var();
                new GUI();
                new Label();
                new ActionHandler();
        }
}

如果我在标签 class 中放置一个 System.out.println("Test");,我不会得到输出。 这是标签 class:

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JLabel;

public class Label extends JLabel {
        private static final long serialVersionUID = 1L;
        protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                Graphics2D g2d = (Graphics2D) g;
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                g.drawImage(Var.ibackground, 0, 0, 1920, 1080, null);
        }
}

提前致谢, 狼疮

您的标签对象肯定已创建,但由于它未添加到 GUI 视图层次结构中,因此永远不会被使用 - 因此没有人会在其上调用 paintComponent()