InitialFTP.java 904 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
  @test
  @bug       7125044
  @summary   Tests defaut focus traversal policy in AWT & Swing toplevel windows.
  @author    anton.tarasov@sun.com: area=awt.focus
  @run       main InitialFTP_AWT
  @run       main InitialFTP_Swing
*/

import java.awt.FocusTraversalPolicy;
import java.awt.Window;

public class InitialFTP {
    public static void test(Window win, Class<? extends FocusTraversalPolicy> expectedPolicy) {
        FocusTraversalPolicy ftp = win.getFocusTraversalPolicy();

        System.out.println("==============" + "\n" +
                           "Tested window:    " + win + "\n" +
                           "Expected policy:  " + expectedPolicy + "\n" +
                           "Effective policy: " + ftp.getClass());

        if (!expectedPolicy.equals(ftp.getClass())) {
            throw new RuntimeException("Test failed: wrong effective focus policy");
        }
    }
}