Java JFrame Center alignCenter(JInternalFrame internalFrame)

Here you can find the source of alignCenter(JInternalFrame internalFrame)

Description

align Center

License

Open Source License

Declaration

public static void alignCenter(JInternalFrame internalFrame) 

Method Source Code


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

import java.awt.Point;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;

public class Main {
    public static void alignCenter(JInternalFrame internalFrame) {

        JDesktopPane desktopPane = internalFrame.getDesktopPane();

        int desktopWidth = desktopPane.getWidth();
        int desktopHeight = desktopPane.getHeight();
        int frameWidth = internalFrame.getWidth();
        int frameHeight = internalFrame.getHeight();

        Point newLocation = new Point((desktopWidth - frameWidth) / 2, (desktopHeight - frameHeight) / 2);

        internalFrame.setLocation(newLocation);
    }/*from   w w w .j a  v  a 2  s  .  com*/
}

Related

  1. center(JFrame frame)
  2. center(JFrame frame)
  3. center(JFrame parent, JInternalFrame dialog)
  4. centerAndSizeFrame(JFrame frame)