test/java/awt/Mixing/AWT_Mixing/MixingPanelsResizing.java

Print this page




   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 import java.awt.*;
  26 import java.awt.event.InputEvent;
  27 import javax.swing.*;
  28 import java.io.*;

  29 
  30 /**
  31  * AWT/Swing overlapping test for Panel and JPanel behavior during resizing.
  32  * <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6786219">JDK-6786219</a> for details
  33  */
  34 /*
  35 @test
  36 @bug 6786219
  37 @summary Issues when resizing the frame after mixing of heavy weight & light weight components
  38 @author sergey.grinev@oracle.com: area=awt.mixing


  39 @build FrameBorderCounter
  40 @run main MixingPanelsResizing
  41  */
  42 public class MixingPanelsResizing {
  43 
  44     static volatile boolean failed = false;
  45 
  46     private static JFrame frame;
  47     private static JButton jbutton;
  48     private static Button awtButton;
  49     private static JButton jbutton2;
  50     private static Button awtButton2;
  51     private static final Color jbColor = Color.RED;
  52     private static final Color awtColor = Color.ORANGE;
  53     private static final Color jb2Color = Color.BLUE;
  54     private static final Color awt2Color = Color.CYAN;
  55     private static final int ROBOT_DELAY = 500;
  56 
  57     private static Point lLoc;
  58     private static int borderShift;


 348 to read and understand someone else's test.
 349  ****************************************************/
 350 /**
 351 This is part of the standard test machinery.
 352 It creates a dialog (with the instructions), and is the interface
 353 for sending text messages to the user.
 354 To print the instructions, send an array of strings to Sysout.createDialog
 355 WithInstructions method.  Put one line of instructions per array entry.
 356 To display a message for the tester to see, simply call Sysout.println
 357 with the string to be displayed.
 358 This mimics System.out.println but works within the test harness as well
 359 as standalone.
 360  */
 361 class Sysout {
 362 
 363     private static TestDialog dialog;
 364 
 365     public static void createDialogWithInstructions(String[] instructions) {
 366         dialog = new TestDialog(new Frame(), "Instructions");
 367         dialog.printInstructions(instructions);
 368         dialog.setVisible(true);
 369         println("Any messages for the tester will display here.");
 370     }
 371 
 372     public static void createDialog() {
 373         dialog = new TestDialog(new Frame(), "Instructions");
 374         String[] defInstr = {"Instructions will appear here. ", ""};
 375         dialog.printInstructions(defInstr);
 376         dialog.setVisible(true);
 377         println("Any messages for the tester will display here.");
 378     }
 379 
 380     public static void printInstructions(String[] instructions) {
 381         dialog.printInstructions(instructions);
 382     }
 383 
 384     public static void println(String messageIn) {
 385         dialog.displayMessage(messageIn);
 386         System.out.println(messageIn);
 387     }
 388 }// Sysout  class
 389 
 390 /**
 391 This is part of the standard test machinery.  It provides a place for the
 392 test instructions to be displayed, and a place for interactive messages
 393 to the user to be displayed.
 394 To have the test instructions displayed, see Sysout.
 395 To have a message to the user be displayed, see Sysout.
 396 Do not call anything in this dialog directly.
 397  */
 398 class TestDialog extends Dialog {
 399 
 400     TextArea instructionsText;
 401     TextArea messageText;
 402     int maxStringLength = 80;
 403 
 404     //DO NOT call this directly, go through Sysout
 405     public TestDialog(Frame frame, String name) {
 406         super(frame, name);
 407         int scrollBoth = TextArea.SCROLLBARS_BOTH;
 408         instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
 409         add("North", instructionsText);
 410 
 411         messageText = new TextArea("", 5, maxStringLength, scrollBoth);
 412         add("Center", messageText);
 413 
 414         pack();
 415 
 416         setVisible(true);
 417     }// TestDialog()
 418 
 419     //DO NOT call this directly, go through Sysout
 420     public void printInstructions(String[] instructions) {
 421         //Clear out any current instructions
 422         instructionsText.setText("");
 423 
 424         //Go down array of instruction strings
 425 
 426         String printStr, remainingStr;
 427         for (int i = 0; i < instructions.length; i++) {
 428             //chop up each into pieces maxSringLength long
 429             remainingStr = instructions[i];
 430             while (remainingStr.length() > 0) {
 431                 //if longer than max then chop off first max chars to print
 432                 if (remainingStr.length() >= maxStringLength) {
 433                     //Try to chop on a word boundary
 434                     int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1);
 435 
 436                     if (posOfSpace <= 0) {




   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 import java.awt.*;
  26 import java.awt.event.InputEvent;
  27 import javax.swing.*;
  28 import java.io.*;
  29 import test.java.awt.regtesthelpers.Util;
  30 
  31 /**
  32  * AWT/Swing overlapping test for Panel and JPanel behavior during resizing.
  33  * <p>See <a href="https://bugs.openjdk.java.net/browse/JDK-6786219">JDK-6786219</a> for details
  34  */
  35 /*
  36 @test
  37 @bug 6786219
  38 @summary Issues when resizing the frame after mixing of heavy weight & light weight components
  39 @author sergey.grinev@oracle.com: area=awt.mixing
  40 @library ../../regtesthelpers
  41 @build Util
  42 @build FrameBorderCounter
  43 @run main MixingPanelsResizing
  44  */
  45 public class MixingPanelsResizing {
  46 
  47     static volatile boolean failed = false;
  48 
  49     private static JFrame frame;
  50     private static JButton jbutton;
  51     private static Button awtButton;
  52     private static JButton jbutton2;
  53     private static Button awtButton2;
  54     private static final Color jbColor = Color.RED;
  55     private static final Color awtColor = Color.ORANGE;
  56     private static final Color jb2Color = Color.BLUE;
  57     private static final Color awt2Color = Color.CYAN;
  58     private static final int ROBOT_DELAY = 500;
  59 
  60     private static Point lLoc;
  61     private static int borderShift;


 351 to read and understand someone else's test.
 352  ****************************************************/
 353 /**
 354 This is part of the standard test machinery.
 355 It creates a dialog (with the instructions), and is the interface
 356 for sending text messages to the user.
 357 To print the instructions, send an array of strings to Sysout.createDialog
 358 WithInstructions method.  Put one line of instructions per array entry.
 359 To display a message for the tester to see, simply call Sysout.println
 360 with the string to be displayed.
 361 This mimics System.out.println but works within the test harness as well
 362 as standalone.
 363  */
 364 class Sysout {
 365 
 366     private static TestDialog dialog;
 367 
 368     public static void createDialogWithInstructions(String[] instructions) {
 369         dialog = new TestDialog(new Frame(), "Instructions");
 370         dialog.printInstructions(instructions);
 371         //dialog.setVisible(true);
 372         println("Any messages for the tester will display here.");
 373     }
 374 
 375     public static void createDialog() {
 376         dialog = new TestDialog(new Frame(), "Instructions");
 377         String[] defInstr = {"Instructions will appear here. ", ""};
 378         dialog.printInstructions(defInstr);
 379         //dialog.setVisible(true);
 380         println("Any messages for the tester will display here.");
 381     }
 382 
 383     public static void printInstructions(String[] instructions) {
 384         dialog.printInstructions(instructions);
 385     }
 386 
 387     public static void println(String messageIn) {
 388         dialog.displayMessage(messageIn);
 389         System.out.println(messageIn);
 390     }
 391 }// Sysout  class
 392 
 393 /**
 394 This is part of the standard test machinery.  It provides a place for the
 395 test instructions to be displayed, and a place for interactive messages
 396 to the user to be displayed.
 397 To have the test instructions displayed, see Sysout.
 398 To have a message to the user be displayed, see Sysout.
 399 Do not call anything in this dialog directly.
 400  */
 401 class TestDialog extends Dialog {
 402 
 403     TextArea instructionsText;
 404     TextArea messageText;
 405     int maxStringLength = 80;
 406 
 407     //DO NOT call this directly, go through Sysout
 408     public TestDialog(Frame frame, String name) {
 409         super(frame, name);
 410         int scrollBoth = TextArea.SCROLLBARS_BOTH;
 411         instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
 412         add("North", instructionsText);
 413 
 414         messageText = new TextArea("", 5, maxStringLength, scrollBoth);
 415         add("Center", messageText);
 416 
 417         pack();
 418 
 419         //setVisible(true);
 420     }// TestDialog()
 421 
 422     //DO NOT call this directly, go through Sysout
 423     public void printInstructions(String[] instructions) {
 424         //Clear out any current instructions
 425         instructionsText.setText("");
 426 
 427         //Go down array of instruction strings
 428 
 429         String printStr, remainingStr;
 430         for (int i = 0; i < instructions.length; i++) {
 431             //chop up each into pieces maxSringLength long
 432             remainingStr = instructions[i];
 433             while (remainingStr.length() > 0) {
 434                 //if longer than max then chop off first max chars to print
 435                 if (remainingStr.length() >= maxStringLength) {
 436                     //Try to chop on a word boundary
 437                     int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1);
 438 
 439                     if (posOfSpace <= 0) {