InitialFTP_Swing.java revision 8729:0242fce0f717
1/* 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/* 25 @bug 7125044 26 @summary Tests default focus traversal policy in Swing toplevel windows. 27 @author anton.tarasov@sun.com: area=awt.focus 28*/ 29 30import java.awt.FlowLayout; 31import java.awt.FocusTraversalPolicy; 32import java.awt.Window; 33import javax.swing.JButton; 34import javax.swing.JFrame; 35import javax.swing.JList; 36import javax.swing.JTextArea; 37import javax.swing.LayoutFocusTraversalPolicy; 38 39public class InitialFTP_Swing { 40 public static void main(String[] args) { 41 SwingFrame f0 = new SwingFrame("frame0"); 42 f0.setVisible(true); 43 44 InitialFTP.test(f0, LayoutFocusTraversalPolicy.class); 45 46 SwingFrame f1 = new SwingFrame("frame1"); 47 f1.setVisible(true); 48 49 InitialFTP.test(f1, LayoutFocusTraversalPolicy.class); 50 51 System.out.println("Test passed."); 52 } 53} 54 55class SwingFrame extends JFrame { 56 JButton button = new JButton("button"); 57 JTextArea text = new JTextArea("qwerty"); 58 JList list = new JList(new String[] {"one", "two", "three"}); 59 60 public SwingFrame(String title) { 61 super(title); 62 63 this.setLayout(new FlowLayout()); 64 this.add(button); 65 this.add(text); 66 this.add(list); 67 this.pack(); 68 } 69} 70