2129N/A /*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
2129N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2129N/A *
2129N/A * This code is free software; you can redistribute it and/or modify it
2129N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
2129N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
2129N/A *
2129N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2129N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2129N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2129N/A * version 2 for more details (a copy is included in the LICENSE file that
2129N/A * accompanied this code).
2129N/A *
2129N/A * You should have received a copy of the GNU General Public License version
2129N/A * 2 along with this work; if not, write to the Free Software Foundation,
2129N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2129N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2129N/A */
2129N/A
2129N/A/*
2129N/A test
2129N/A @bug 6242241
2129N/A @summary Tests basic DnD functionality in an applet
2129N/A @author Your Name: Alexey Utkin area=dnd
2129N/A @run applet/manual=yesno DnDFileGroupDescriptor.html
2129N/A*/
2129N/A
2129N/Aimport java.applet.Applet;
2129N/Aimport java.awt.*;
2129N/A
2129N/Apublic class DnDFileGroupDescriptor extends Applet {
2129N/A public void init() {
2129N/A setLayout(new BorderLayout());
2129N/A
2129N/A String[] instructions = {
2129N/A "The applet window contains a red field.",
2129N/A "1. Start MS Outlook program. Find and open ",
2129N/A " the mail form with attachments.",
2129N/A "2. Select attachments from the mail and drag into a red field of applet.",
2129N/A " When the mouse enters the field during the drag, the application ",
2129N/A " should change the cursor form to OLE-copy and field color to yellow.",
2129N/A "3. Release the mouse button (drop attachments) over the field.",
2129N/A "",
2129N/A "File paths in temporary folder should appear.",
2129N/A "",
2129N/A "You should be able to repeat this operation multiple times.",
2129N/A "Please, select \"Pass\" just in case of success or \"Fail\" for another."
2129N/A };
2129N/A Sysout.createDialogWithInstructions( instructions );
2129N/A }
2129N/A
2129N/A public void start() {
2129N/A Panel mainPanel;
2129N/A Component dropTarget;
2129N/A
2129N/A mainPanel = new Panel();
2129N/A mainPanel.setLayout(new BorderLayout());
2129N/A
2129N/A mainPanel.setBackground(Color.blue);
2129N/A dropTarget = new DnDTarget(Color.red, Color.yellow);
2129N/A
2129N/A mainPanel.add(dropTarget, "Center");
2129N/A add(mainPanel);
2129N/A
2129N/A setSize(200,200);
2129N/A }
2129N/A}
2129N/A
2129N/A/****************************************************
2129N/A Standard Test Machinery
2129N/A DO NOT modify anything below -- it's a standard
2129N/A chunk of code whose purpose is to make user
2129N/A interaction uniform, and thereby make it simpler
2129N/A to read and understand someone else's test.
2129N/A ****************************************************/
2129N/A
2129N/Aclass Sysout
2129N/A {
2129N/A private static TestDialog dialog;
2129N/A
2129N/A public static void createDialogWithInstructions( String[] instructions )
2129N/A {
2129N/A dialog = new TestDialog( new Frame(), "Instructions" );
2129N/A dialog.printInstructions( instructions );
2129N/A dialog.show();
2129N/A println( "Any messages for the tester will display here." );
2129N/A }
2129N/A
2129N/A public static void createDialog( )
2129N/A {
2129N/A dialog = new TestDialog( new Frame(), "Instructions" );
2129N/A String[] defInstr = { "Instructions will appear here. ", "" } ;
2129N/A dialog.printInstructions( defInstr );
2129N/A dialog.show();
2129N/A println( "Any messages for the tester will display here." );
2129N/A }
2129N/A
2129N/A
2129N/A public static void printInstructions( String[] instructions )
2129N/A {
2129N/A dialog.printInstructions( instructions );
2129N/A }
2129N/A
2129N/A
2129N/A public static void println( String messageIn )
2129N/A {
2129N/A dialog.displayMessage( messageIn );
2129N/A }
2129N/A
2129N/A }// Sysout class
2129N/A
2129N/Aclass TestDialog extends Dialog
2129N/A {
2129N/A
2129N/A TextArea instructionsText;
2129N/A TextArea messageText;
2129N/A int maxStringLength = 80;
2129N/A
2129N/A //DO NOT call this directly, go through Sysout
2129N/A public TestDialog( Frame frame, String name )
2129N/A {
2129N/A super( frame, name );
2129N/A int scrollBoth = TextArea.SCROLLBARS_BOTH;
2129N/A instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
2129N/A add( "North", instructionsText );
2129N/A
2129N/A messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
2129N/A add("South", messageText);
2129N/A
2129N/A pack();
2129N/A
2129N/A show();
2129N/A }// TestDialog()
2129N/A
2129N/A //DO NOT call this directly, go through Sysout
2129N/A public void printInstructions( String[] instructions )
2129N/A {
2129N/A //Clear out any current instructions
2129N/A instructionsText.setText( "" );
2129N/A
2129N/A //Go down array of instruction strings
2129N/A
2129N/A String printStr, remainingStr;
2129N/A for( int i=0; i < instructions.length; i++ )
2129N/A {
2129N/A //chop up each into pieces maxSringLength long
2129N/A remainingStr = instructions[ i ];
2129N/A while( remainingStr.length() > 0 )
2129N/A {
2129N/A //if longer than max then chop off first max chars to print
2129N/A if( remainingStr.length() >= maxStringLength )
2129N/A {
2129N/A //Try to chop on a word boundary
2129N/A int posOfSpace = remainingStr.
2129N/A lastIndexOf( ' ', maxStringLength - 1 );
2129N/A
2129N/A if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
2129N/A
2129N/A printStr = remainingStr.substring( 0, posOfSpace + 1 );
2129N/A remainingStr = remainingStr.substring( posOfSpace + 1 );
2129N/A }
2129N/A //else just print
2129N/A else
2129N/A {
2129N/A printStr = remainingStr;
2129N/A remainingStr = "";
2129N/A }
2129N/A
2129N/A instructionsText.append( printStr + "\n" );
2129N/A
2129N/A }// while
2129N/A
2129N/A }// for
2129N/A
2129N/A }//printInstructions()
2129N/A
2129N/A //DO NOT call this directly, go through Sysout
2129N/A public void displayMessage( String messageIn )
2129N/A {
2129N/A messageText.append( messageIn + "\n" );
2129N/A }
2129N/A
2129N/A }// TestDialog class