SizingWindowswithToolkit.java Source code

Java tutorial

Introduction

Here is the source code for SizingWindowswithToolkit.java

Source

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;

public class SizingWindowswithToolkit {
    public static void main(String[] args) {
        JFrame aWindow = new JFrame("This is the Window Title");
        Toolkit theKit = aWindow.getToolkit();
        Dimension wndSize = theKit.getScreenSize();
        aWindow.setBounds(wndSize.width / 4, wndSize.height / 4, // Position
                wndSize.width / 2, wndSize.height / 2); // Size
        aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        aWindow.setVisible(true);
    }
}