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

/**
 * Create a window 
 * place it in center of monitor with size 1/2 the screen size
 * add background color   
 */

public class Awindow2
{
    public static void main(String[] args)
    {

        JFrame win = new JFrame("Position window to center of screen");

        Toolkit UI = win.getToolkit();                      //get ref to UI environment

        Dimension dim = UI.getScreenSize();                 //get width & height of monitor             

        System.out.println(dim);                            //print the monitor screen size

        win.setBounds(dim.width/4, dim.height/4,            //set position to 1/4 monitor size 
              dim.width/2, dim.height/2);                   //set window size to 1/2 monitor size

        win.setDefaultCloseOperation(win.EXIT_ON_CLOSE);    //action when you press X

        win.setVisible(true);                               //make it visible

        Container panel = win.getContentPane();             //get ref to contentPane

        Color c = new Color(200,255,255);                   //create an RGB color

        panel.setBackground(c);                             //set panel background color    
    }
}