次のようなコンストラクタを持つダイアログ クラスがあります。
public SampleDialog(JComponent parent, String title){
super((Frame)SwingUtilities.getAncestorOfClass(Frame.class, parent), title, false);
setLocationRelativeTo(parent);
init();
}
ただし、これにより、右上隅が親の中央になるようにダイアログが配置されます。ダイアログの中心を親コンポーネントの中心の上に置きたいです。どうすればいいですか?私は何か間違ったことをしていますか?