Java examples for Swing:JDialog
Used to center the JDialog.
//package com.java2s; import javax.swing.JDialog; import javax.swing.JFrame; public class Main { /**//from w ww . j av a 2 s. c o m * Used to centre the dialogs. */ public static void centreOnParent(final JDialog dialog, final JFrame frame) { int x = frame.getX(); x += (frame.getWidth() - dialog.getWidth()) / 2; int y = frame.getY(); y += (frame.getHeight() - dialog.getHeight()) / 2; dialog.setLocation(x, y); } }