JButtonInGlassPane.java revision 886
886N/A * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 886N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 886N/A * This code is free software; you can redistribute it and/or modify it 886N/A * under the terms of the GNU General Public License version 2 only, as 886N/A * published by the Free Software Foundation. 886N/A * This code is distributed in the hope that it will be useful, but WITHOUT 886N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 886N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 886N/A * version 2 for more details (a copy is included in the LICENSE file that 886N/A * accompanied this code). 886N/A * You should have received a copy of the GNU General Public License version 886N/A * 2 along with this work; if not, write to the Free Software Foundation, 886N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 886N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 886N/A * CA 95054 USA or visit www.sun.com if you need additional information or 886N/A @summary Tests if a LW components in the glass pane affects HW in the content pane 886N/A @author anthony.petrov@...: area=awt.mixing 886N/A @library ../regtesthelpers 886N/A @run main JButtonInGlassPane 886N/A * summary: Tests whether a LW menu correctly overlaps a HW button 886N/A //*** Create instructions for the user here *** 886N/A "This is an AUTOMATIC test, simply wait until it is done.",
886N/A "The result (passed or failed) will be shown in the",
886N/A "message window below." 886N/A // Click the LW button - in the area that intersects with 886N/A // Now click on the 'added' area of the LW button that again 886N/A // intersects with the HW. 886N/A /***************************************************** 886N/A * Standard Test Machinery Section 886N/A * DO NOT modify anything in this section -- it's a 886N/A * standard chunk of code which has all of the 886N/A * synchronisation necessary for the test harness. 886N/A * By keeping it the same in all tests, it is easier 886N/A * to read and understand someone else's test, as 886N/A * well as insuring that all tests behave correctly 886N/A * with the test harness. 886N/A * There is a section following this for test- 886N/A ******************************************************/ 886N/A // Not sure about what happens if multiple of this test are 886N/A // instantiated in the same VM. Being static (and using 886N/A // static vars), it aint gonna work. Not worrying about 886N/A //The test passed, so just return from main and harness will 886N/A // interepret this return as a pass 886N/A //At this point, neither test pass nor test fail has been 886N/A // called -- either would have thrown an exception and ended the 886N/A // test, so we know we have multiple threads. 886N/A //Test involves other threads, so sleep and wait for them to 886N/A // called pass() or fail() 886N/A //Timed out, so fail the test 886N/A //The test harness may have interrupted the test. If so, rethrow the exception 886N/A // so that the harness gets it and deals with it. 886N/A //reset flag in case hit this code more than once for some reason (just safety) 886N/A //first check if this is executing in main thread 886N/A //Still in the main thread, so set the flag just for kicks, 886N/A // and throw a test passed exception which will be caught 886N/A //test writer didn't specify why test failed, so give generic 886N/A //check if this called from main thread 886N/A //If main thread, fail now 'cause not sleeping 886N/A}
// class JButtonInGlassPane 886N/A//This exception is used to exit from any level of call nesting 886N/A// when it's determined that the test has passed, and immediately 886N/A//*********** End Standard Test Machinery Section ********** 886N/A//************ Begin classes defined for the test **************** 886N/A// if want to make listeners, here is the recommended place for them, then instantiate 886N/A/* Example of a class which may be written as part of a test 886N/Aclass NewClass implements anInterface 886N/A public void eventDispatched(AWTEvent e) 886N/A //Counting events to see if we get enough 886N/A //got enough events, so pass 886N/A JButtonInGlassPane.pass(); 886N/A //tried too many times without getting enough events so fail 886N/A JButtonInGlassPane.fail(); 886N/A//************** End classes defined for the test ******************* 886N/A/**************************************************** 886N/A Standard Test Machinery 886N/A DO NOT modify anything below -- it's a standard 886N/A chunk of code whose purpose is to make user 886N/A interaction uniform, and thereby make it simpler 886N/A to read and understand someone else's test. 886N/A ****************************************************/ 886N/A This is part of the standard test machinery. 886N/A It creates a dialog (with the instructions), and is the interface 886N/A for sending text messages to the user. 886N/A To print the instructions, send an array of strings to Sysout.createDialog 886N/A WithInstructions method. Put one line of instructions per array entry. 886N/A To display a message for the tester to see, simply call Sysout.println 886N/A with the string to be displayed. 886N/A This mimics System.out.println but works within the test harness as well 886N/A println(
"Any messages for the tester will display here." );
886N/A println(
"Any messages for the tester will display here." );
886N/A This is part of the standard test machinery. It provides a place for the 886N/A test instructions to be displayed, and a place for interactive messages 886N/A to the user to be displayed. 886N/A To have the test instructions displayed, see Sysout. 886N/A To have a message to the user be displayed, see Sysout. 886N/A Do not call anything in this dialog directly. 886N/A //DO NOT call this directly, go through Sysout 886N/A //DO NOT call this directly, go through Sysout 886N/A //Clear out any current instructions 886N/A //Go down array of instruction strings 886N/A //chop up each into pieces maxSringLength long 886N/A //if longer than max then chop off first max chars to print 886N/A //Try to chop on a word boundary 886N/A //DO NOT call this directly, go through Sysout