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