static void centerComponent(Component c) {
DisplayMode dm = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0].getDisplayMode();
Dimension dim = c.getPreferredSize();
c.setLocation((dm.getWidth() - dim.width) / 2, (dm.getHeight() - dim.height) / 2);
}