import javax.swing.*;
import java.awt.*;
/**
* @author Adrian BER (beradrian@yahoo.com)
*/
publicclass UIUtilities {
publicstaticvoid setFrameLocationRelativeTo(JFrame f, Component c) {
if (c == null) {
// Setting the position of the dialog on the center of the screen
// in 1.4 should be replaced by
// f.setLocationRelativeTo(null);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
f.setLocation((int)d.getWidth()/2 - (int)f.getPreferredSize().getWidth()/2,
(int)d.getHeight()/2 - (int)f.getPreferredSize().getHeight()/2);
}
}
}