Java JDialog alignDialogInMiddleOfScreen(JDialog dlg)

Here you can find the source of alignDialogInMiddleOfScreen(JDialog dlg)

Description

align Dialog In Middle Of Screen

License

Apache License

Declaration

private static void alignDialogInMiddleOfScreen(JDialog dlg) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;

import java.awt.*;

public class Main {
    private static void alignDialogInMiddleOfScreen(JDialog dlg) {
        Rectangle frameBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
        int x = frameBounds.x + ((frameBounds.width - dlg.getSize().width) / 2);
        int y = frameBounds.y + ((frameBounds.height - dlg.getSize().height) / 2);
        dlg.setLocation(x, y);//  w  w  w . j a va 2  s . co m
    }
}

Related

  1. adaptSize(JDialog frame, int preferredWidth, int preferredHeight)
  2. addFileOnAction(AbstractButton button, final JTextField textField, final JDialog parent)
  3. applyDefaultProperties(final JDialog comp)
  4. calculatePosition(Window parent, JDialog dialog)
  5. cascadeDialog(JDialog dialog, JDialog parent)
  6. chooseFile(final JDialog dialog, final String title)