Source Code : Set Frame Location Relative To

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Set Frame Location Relative To

   


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

/**
 * @author Adrian BER (beradrian@yahoo.com)
 */
public class UIUtilities {


    public static void setFrameLocationRelativeTo(JFrame f, Component c) {
        if (c == null) {
            // Setting the position of the dialog on the center of the screen
            // in 1.4 should be replaced by
//             f.setLocationRelativeTo(null);
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
            f.setLocation((int)d.getWidth()/2 - (int)f.getPreferredSize().getWidth()/2,
                    (int)d.getHeight()/2 - (int)f.getPreferredSize().getHeight()/2);
        }
    }
}

   
    
    
  

Thank with us