import javax.swing.*; public class Example { public static void main(String[] args) { JLabel label = new JLabel("Hello World!"); label.setVisible(true); } }
import javax.swing.*; public class Example { public static void main(String[] args) { JFrame frame = new JFrame("Example"); JLabel label = new JLabel("Hello World!"); frame.add(label); frame.pack(); frame.setVisible(false); label.setVisible(true); } }Both examples rely on the javax.swing package library.