Making the JFrame window appear at center of screen

How can i making the JFrame window appear at center of screen, just like JOptionPane?
[92 byte] By [sakuraleea] at [2007-11-26 21:59:31]
# 1
Toolkit tk = Toolkit.getDefaultToolkit();Dimension screenSize = tk.getScreenSize();int screenHeight = screenSize.height;int screenWidth = screenSize.width;setLocation((screenWidth - framewidth)/2,
JTable_need_infoa at 2007-7-10 3:58:33 > top of Java-index,Desktop,Core GUI APIs...
# 2
You can center JFrame on screen like this:JFrame f = new JFrame();f.setLocationRelativeTo(null);
Toxtera at 2007-7-10 3:58:33 > top of Java-index,Desktop,Core GUI APIs...