JLabel label = new JLabel("Hello World!"); label.setBounds(50, 50, 100, 30);
JLabel label = new JLabel(new ImageIcon("image.png")); label.setBounds(0, 0, 200, 200);This code creates a JLabel with an image "image.png" and sets the position to (0, 0) and size to (200, 200). Both examples use the javax.swing package library. The setBounds method is part of the JLabel class, which is included in this package library.