JLabel label = new JLabel("Hello World"); label.setForeground(Color.RED);
JLabel label = new JLabel(new ImageIcon("image.png")); label.setForeground(Color.WHITE);In this example, we create a JLabel with an image and set the foreground color of the text to white. The image can be loaded using the ImageIcon class. Package Library: javax.swing.JLabel is part of the Java Swing library.