JLabel label = new JLabel("Hello World"); label.setLocation(50, 50);
JLabel iconLabel = new JLabel(new ImageIcon("image.png")); iconLabel.setLocation(100, 100);This code creates a new JLabel instance with an image icon loaded from the file "image.png" and sets its location to (100, 100) relative to its parent container. The javax.swing package library provides classes and interfaces for creating and managing graphical user interfaces in Java.