Java JFrame Center centerFrameTo(final JFrame frameToCenter, final Dimension orientDim)

Here you can find the source of centerFrameTo(final JFrame frameToCenter, final Dimension orientDim)

Description

center Frame To

License

Apache License

Declaration

public static void centerFrameTo(final JFrame frameToCenter, final Dimension orientDim) 

Method Source Code

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

import java.awt.Dimension;

import javax.swing.JFrame;

public class Main {
    public static void centerFrameTo(final JFrame frameToCenter, final Dimension orientDim) {
        Dimension frameSize = frameToCenter.getSize();
        int x = (orientDim.width - frameSize.width) / 2;
        int y = (orientDim.height - frameSize.height) / 2;
        frameToCenter.setLocation(x, y);
    }//  w  w  w.j ava  2  s .  c o m
}

Related

  1. centerFrame(JFrame frame, boolean isPopup)
  2. centerFrame(Window owner)
  3. centerFrameOnMainDisplay(final JFrame frame)
  4. centerFrameOnScreen(JFrame frame)
  5. centerFrameOnScreen(JFrame frame)
  6. centerJFrame(JFrame frame)
  7. centerOnFrame(JDialog dialog, JFrame frame)
  8. centerOnFrame(JFrame frame, Component comp)
  9. centerOnParent(JDialog child, JFrame parent)