test/jdk/java/awt/List/KeyEventsTest/KeyEventsTest.java
changeset 54231 e4813eded7cb
parent 51637 e9177e7749e7
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25   test
    25   @test
       
    26   @key headful
    26   @bug 6190768 6190778
    27   @bug 6190768 6190778
    27   @summary Tests that triggering events on AWT list by pressing CTRL + HOME, CTRL + END, PG-UP, PG-DOWN similar Motif behavior
    28   @summary Tests that triggering events on AWT list by pressing CTRL + HOME,
    28   @author Dmitry.Cherepanov@SUN.COM area=awt.list
    29            CTRL + END, PG-UP, PG-DOWN similar Motif behavior
    29   @library /test/lib
    30   @library /test/lib
    30   @build jdk.test.lib.Platform
    31   @build jdk.test.lib.Platform
    31   @run applet KeyEventsTest.html
    32   @run main KeyEventsTest
    32 */
    33 */
    33 
    34 
    34 /**
       
    35  * KeyEventsTest.html
       
    36  *
       
    37  * summary:
       
    38  */
       
    39 
       
    40 import java.applet.Applet;
       
    41 import java.awt.*;
    35 import java.awt.*;
    42 import java.awt.event.*;
    36 import java.awt.event.*;
    43 import java.util.Set;
       
    44 import java.lang.reflect.*;
    37 import java.lang.reflect.*;
    45 
    38 
    46 import jdk.test.lib.Platform;
    39 import jdk.test.lib.Platform;
    47 
    40 
    48 public class KeyEventsTest extends Applet implements ItemListener, FocusListener, KeyListener
    41 public class KeyEventsTest extends Frame implements ItemListener, FocusListener, KeyListener
    49 {
    42 {
    50     TestState currentState;
    43     TestState currentState;
    51     final Object LOCK = new Object();
    44     final Object LOCK = new Object();
    52     final int ACTION_TIMEOUT = 500;
    45     final int ACTION_TIMEOUT = 500;
    53 
    46 
    54     List single = new List(3, false);
    47     List single = new List(3, false);
    55     List multiple = new List(3, true);
    48     List multiple = new List(3, true);
    56 
    49 
    57     Panel p1 = new Panel ();
    50     Panel p1 = new Panel ();
    58     Panel p2 = new Panel ();
    51     Panel p2 = new Panel ();
       
    52 
       
    53     public static void main(final String[] args) {
       
    54         KeyEventsTest app = new KeyEventsTest();
       
    55         app.init();
       
    56         app.start();
       
    57     }
    59 
    58 
    60     public void init()
    59     public void init()
    61     {
    60     {
    62         setLayout (new BorderLayout ());
    61         setLayout (new BorderLayout ());
    63 
    62 
    98     public void start ()
    97     public void start ()
    99     {
    98     {
   100 
    99 
   101         try{
   100         try{
   102             setSize (200,200);
   101             setSize (200,200);
       
   102             validate();
       
   103             setUndecorated(true);
       
   104             setLocationRelativeTo(null);
   103             setVisible(true);
   105             setVisible(true);
   104             validate();
   106 
   105 
   107             doTest();
   106             main(null);
   108             System.out.println("Test passed.");
   107 
       
   108         } catch (Exception e) {
   109         } catch (Exception e) {
   109             e.printStackTrace();
   110             e.printStackTrace();
   110             throw new RuntimeException("The test failed.");
   111             throw new RuntimeException("The test failed.");
   111         }
   112         }
   112 
   113 
   113     }// start()
   114     }// start()
   114 
       
   115     private void main(String[] args)
       
   116       throws InterruptedException, InvocationTargetException {
       
   117 
       
   118         doTest();
       
   119 
       
   120         System.out.println("Test passed.");
       
   121     }
       
   122 
   115 
   123     public void itemStateChanged (ItemEvent ie) {
   116     public void itemStateChanged (ItemEvent ie) {
   124         System.out.println("itemStateChanged-"+ie);
   117         System.out.println("itemStateChanged-"+ie);
   125         this.currentState.setAction(true);
   118         this.currentState.setAction(true);
   126     }
   119     }