how to center something in java panel code example Example: jlabel on the center of a jpanel panel.setLayout(new GridBagLayout()); panel.add(label);