Java tutorial
import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Main { public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = (JPanel) frame.getContentPane(); panel.setLayout(null); JLabel label = new JLabel("aaa"); panel.add(label); Dimension size = label.getPreferredSize(); label.setBounds(100, 100, size.width, size.height); frame.setSize(300, 200); frame.setVisible(true); } }