java/awt/color/XAWTDifference/XAWTDifference.java

Print this page


   1 /*























   2    test
   3    @bug        5092883 6513478
   4    @summary    REGRESSION: SystemColor class gives back wrong values under Linux
   5    @author     andrei.dmitriev : area=awt.color
   6    @run applet/manual=yesno XAWTDifference.html
   7 */
   8 
   9 import java.applet.Applet;
  10 import java.awt.event.*;
  11 import java.awt.*;
  12 import java.io.*;
  13 import java.util.Vector;
  14 import java.util.Enumeration;
  15 
  16 public class XAWTDifference extends Applet
  17 {
  18     Robot robot;
  19     Vector containers = new Vector();
  20     Vector disabledContainers = new Vector();
  21     Vector uneditableTextComponents = new Vector();


 111             "The second one with disabled components.",
 112             "The third one with uneditable components(only text components are there).",
 113             "Verify that the difference between different states is visible.",
 114             "II) You would also see a frame named \"StandardFrame\" (2) with lot of components in it.",
 115             "Actually this is just a jpg-image in a frame.",
 116             "This image reflects how Motif components looks like.",
 117             "Verify that every component in the frame (1) looks similar to the same component in (2)",
 118             "They might differ in colors and be darker or brighter but the whole picture should",
 119             "be the same. For your convinience you may use mouse clicks to",
 120             "check color for every point on frame (1) or on image inside frame (2).",
 121             "Also check the color of the MenuBar, Items in the MenuBar and the PopupMenu assigned to TextArea.",
 122             "As you can\'t compare the colors of menu items with the picture so just look if the are adeqaute enough."
 123         };
 124         Sysout.createDialogWithInstructions( instructions );
 125 
 126     }//End  init()
 127 
 128     public void start ()
 129     {
 130         Toolkit toolkit = Toolkit.getDefaultToolkit();
 131 
 132         String toolkitName = Toolkit.getDefaultToolkit().getClass().getName();
 133         if (toolkitName.equals("sun.awt.windows.WToolkit")){
 134             Sysout.println("This test is for XAWT/Motif only. Now using :"+toolkit);
 135             return;
 136         }

 137         String testPath = System.getProperty("test.src", ".");
 138         Sysout.println("test.src == "+testPath);
 139         Frame standardFrame = new StandardFrame("StandardFrame");
 140 
 141         standardFrame.setSize(531, 832);
 142         standardFrame.setVisible(true);
 143 
 144         setVisible(true);
 145         validate();
 146 
 147 
 148         testFrame.setLayout(new GridLayout(1, 3));
 149         testFrame.add(addComponentsIntoPanel(true, true));
 150         testFrame.add(addComponentsIntoPanel(false, true));
 151         testFrame.add(addComponentsIntoPanel(true, false));
 152 
 153         MenuItem mi1 = new MenuItem("Item1");
 154         MenuItem mi2 = new MenuItem("Item2");
 155         MenuItem mi3 = new MenuItem("Disabled Item3");
 156         mi3.setEnabled(false);
 157 
 158         MenuBar mb = new MenuBar();
 159         Menu enabledMenu = new Menu("Enabled Menu");
 160         Menu disabledMenu = new Menu("Disabled Menu");
 161         disabledMenu.setEnabled(false);


 180               }
 181            }
 182         }, MouseEvent.BUTTON1_MASK);
 183 
 184 
 185         testFrame.pack();
 186         testFrame.setVisible(true);
 187     }// start()
 188 }// class XAWTDifference
 189 
 190 /* Place other classes related to the test after this line */
 191 
 192 class StandardFrame extends Frame{
 193     Image image;
 194     public StandardFrame(String name ){
 195         super(name);
 196         String testPath = System.getProperty("test.src", ".");
 197         image = Toolkit.getDefaultToolkit().getImage(testPath + File.separator + "MotifColors.jpg");
 198     }
 199     public void paint(Graphics g){
 200         g.drawImage(image, 0, 0, 531, 832, null);
 201     }
 202 }
 203 
 204 /****************************************************
 205  Standard Test Machinery
 206  DO NOT modify anything below -- it's a standard
 207   chunk of code whose purpose is to make user
 208   interaction uniform, and thereby make it simpler
 209   to read and understand someone else's test.
 210  ****************************************************/
 211 
 212 /**
 213  This is part of the standard test machinery.
 214  It creates a dialog (with the instructions), and is the interface
 215   for sending text messages to the user.
 216  To print the instructions, send an array of strings to Sysout.createDialog
 217   WithInstructions method.  Put one line of instructions per array entry.
 218  To display a message for the tester to see, simply call Sysout.println
 219   with the string to be displayed.
 220  This mimics System.out.println but works within the test harness as well


   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    test
  26    @bug        5092883 6513478
  27    @summary    REGRESSION: SystemColor class gives back wrong values under Linux
  28    @author     andrei.dmitriev : area=awt.color
  29    @run applet/manual=yesno XAWTDifference.html
  30 */
  31 
  32 import java.applet.Applet;
  33 import java.awt.event.*;
  34 import java.awt.*;
  35 import java.io.*;
  36 import java.util.Vector;
  37 import java.util.Enumeration;
  38 
  39 public class XAWTDifference extends Applet
  40 {
  41     Robot robot;
  42     Vector containers = new Vector();
  43     Vector disabledContainers = new Vector();
  44     Vector uneditableTextComponents = new Vector();


 134                         "The second one with disabled components.",
 135                         "The third one with uneditable components(only text components are there).",
 136                         "Verify that the difference between different states is visible.",
 137                         "II) You would also see a frame named \"StandardFrame\" (2) with lot of components in it.",
 138                         "Actually this is just a jpg-image in a frame.",
 139                         "This image reflects how Motif components looks like.",
 140                         "Verify that every component in the frame (1) looks similar to the same component in (2)",
 141                         "They might differ in colors and be darker or brighter but the whole picture should",
 142                         "be the same. For your convinience you may use mouse clicks to",
 143                         "check color for every point on frame (1) or on image inside frame (2).",
 144                         "Also check the color of the MenuBar, Items in the MenuBar and the PopupMenu assigned to TextArea.",
 145                         "As you can\'t compare the colors of menu items with the picture so just look if the are adeqaute enough."
 146                 };
 147         Sysout.createDialogWithInstructions( instructions );
 148 
 149     }//End  init()
 150 
 151     public void start ()
 152     {
 153         Toolkit toolkit = Toolkit.getDefaultToolkit();

 154         String toolkitName = Toolkit.getDefaultToolkit().getClass().getName();
 155         if (!toolkitName.equals("sun.awt.X11.XToolkit")) {
 156             Sysout.println("Press PASS, this test is for XAWT/Motif only. Now using :"+toolkit);
 157             return;
 158         }
 159 
 160         String testPath = System.getProperty("test.src", ".");
 161         Sysout.println("test.src == "+testPath);
 162         Frame standardFrame = new StandardFrame("StandardFrame");
 163 
 164         standardFrame.setSize(417, 667);
 165         standardFrame.setVisible(true);
 166 
 167         setVisible(true);
 168         validate();
 169 
 170 
 171         testFrame.setLayout(new GridLayout(1, 3));
 172         testFrame.add(addComponentsIntoPanel(true, true));
 173         testFrame.add(addComponentsIntoPanel(false, true));
 174         testFrame.add(addComponentsIntoPanel(true, false));
 175 
 176         MenuItem mi1 = new MenuItem("Item1");
 177         MenuItem mi2 = new MenuItem("Item2");
 178         MenuItem mi3 = new MenuItem("Disabled Item3");
 179         mi3.setEnabled(false);
 180 
 181         MenuBar mb = new MenuBar();
 182         Menu enabledMenu = new Menu("Enabled Menu");
 183         Menu disabledMenu = new Menu("Disabled Menu");
 184         disabledMenu.setEnabled(false);


 203                 }
 204             }
 205         }, MouseEvent.BUTTON1_MASK);
 206 
 207 
 208         testFrame.pack();
 209         testFrame.setVisible(true);
 210     }// start()
 211 }// class XAWTDifference
 212 
 213 /* Place other classes related to the test after this line */
 214 
 215 class StandardFrame extends Frame{
 216     Image image;
 217     public StandardFrame(String name ){
 218         super(name);
 219         String testPath = System.getProperty("test.src", ".");
 220         image = Toolkit.getDefaultToolkit().getImage(testPath + File.separator + "MotifColors.jpg");
 221     }
 222     public void paint(Graphics g){
 223         g.drawImage(image, 0, 0, 417, 667, this);
 224     }
 225 }
 226 
 227 /****************************************************
 228  Standard Test Machinery
 229  DO NOT modify anything below -- it's a standard
 230  chunk of code whose purpose is to make user
 231  interaction uniform, and thereby make it simpler
 232  to read and understand someone else's test.
 233  ****************************************************/
 234 
 235 /**
 236  This is part of the standard test machinery.
 237  It creates a dialog (with the instructions), and is the interface
 238  for sending text messages to the user.
 239  To print the instructions, send an array of strings to Sysout.createDialog
 240  WithInstructions method.  Put one line of instructions per array entry.
 241  To display a message for the tester to see, simply call Sysout.println
 242  with the string to be displayed.
 243  This mimics System.out.println but works within the test harness as well