Java JDialog Center centrarVentana(JDialog pDialog)

Here you can find the source of centrarVentana(JDialog pDialog)

Description

centrar Ventana

License

Open Source License

Declaration

public static void centrarVentana(JDialog pDialog) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;
import java.awt.*;

public class Main {
    public static void centrarVentana(JDialog pDialog) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension objectSize = pDialog.getSize();
        if (objectSize.height > screenSize.height) {
            objectSize.height = screenSize.height;
        }//from  w ww . j a v  a 2 s  . c  o  m
        if (objectSize.width > screenSize.width) {
            objectSize.width = screenSize.width;
        }
        pDialog.setLocation((((screenSize.width - objectSize.width) / 2)),
                (screenSize.height - objectSize.height) / 2);
    }
}

Related

  1. centerOn(JDialog dialog, Component other)
  2. centerOnComponent(JDialog dialog, Component comp)
  3. centerOnScreen(JDialog jdialog)
  4. centerWindow(JDialog dialog)
  5. centerWindow(JDialog dialog)
  6. getCentralDialogLocation(Component parent, JDialog dialog)
  7. getCentredDialogBounds(JDialog dialog, Component parent, int defaultWidth, int defaultHeight)
  8. packAndCenterJDialog(JDialog form)
  9. packInCenter(JDialog dialog)