public class TryWindow3
1: //TryWindow3.java
2: //Uses the GraphicsEnvironment class to get
3: //information about the local environment
5: import javax.swing.JFrame;
6: import java.awt.Point;
7: import java.awt.GraphicsEnvironment;
9: public class TryWindow3
10: {
11: static JFrame window = new JFrame("This is the Window Title");
13: public static void main(String[] args)
14: {
15: window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
17: //Set size and position of window, then display it
18: int windowWidth = 400;
19: int windowHeight = 150;
20: Point center = GraphicsEnvironment.getLocalGraphicsEnvironment()
21: .getCenterPoint();
22: window.setBounds(center.x-windowWidth/2, center.y-windowHeight/2,
23: windowWidth, windowHeight);
24: window.setVisible(true);
25: }
26: }