Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1232276

Win32: calling Dialog.move() the second time does nothing.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      x86
    • OS:
      windows_nt
    • Verification:
      Not verified

      Description

      Win 32 only: calling Dialog.move() the second time does nothing.

      Steps to reproduce
      Compile and run the attached code
      Press <Open Modal>
      In dialog box Press <Move>
      Drag dialog box to the other corner of screen
      Press <Move>
      // note: the dialog box should move



      /* Dialog box move tests */

      import java.awt.*;
      import java.applet.Applet;

      public class DialogMoveTest extends Applet
      {
          private Dialog testDialog;
          private Frame parentFrame;
          private TextArea textArea;

          private final String GET_PARENT = "Get Parent";
          private final String OPEN_MODAL = "Open Modal Dialog";
          private final String OPEN_MODELESS = "Open Modeless Dialog";

          public void init()
          {
             setLayout( new BorderLayout() );

             // creat test panel
             Panel tempPanel = new Panel();
             tempPanel.add( new Button(GET_PARENT) );
             tempPanel.add( new Button(OPEN_MODAL) );
             tempPanel.add( new Button(OPEN_MODELESS) );
             add( "North", tempPanel );

             add( "Center", textArea = new TextArea() );
             resize(400, 400);
          }

          public boolean action(Event evt, Object obj)
          {

             if (evt.target instanceof Button)
             {
                String label = (String) obj;

                if ( label.equals(GET_PARENT) )
                {
                   if (parentFrame == null)
                      getParentFrame();
                      
                   textArea.appendText( "Parent: " + parentFrame.toString() + "\\n");
                   textArea.appendText( "Location: " +
                                        parentFrame.location().toString() +
                                        "\\n" );
                }
                else if( label.equals(OPEN_MODELESS) )
                {
                   if ( parentFrame == null )
                      getParentFrame();
                   
                   if ( (testDialog == null) || (! testDialog.isShowing() ) )
                   {
                      testDialog = new TestDialog(parentFrame, "Test Dialog", false);
                      testDialog.resize(200, 200);
                      testDialog.show();
                   }
                }
                else if( label.equals(OPEN_MODAL) )
                {
                   if ( parentFrame == null )
                      getParentFrame();
                   
                   if ( (testDialog == null) || (! testDialog.isShowing() ) )
                   {
                      testDialog = new TestDialog(parentFrame, "Test Dialog", true);
                      testDialog.resize(200, 200);
                      testDialog.show();
                   }
                }
                else
                {
                   // didn't handle button action
                   return false;
                }
                // handled button action
                return true;
             }
             else
             {
                // it's always good form to let the superclass handle
                // events.
                return super.action(evt, obj);
             }
          }


          // Get Applet parent
          private void getParentFrame()
          {
             // local variables
             Container tempContainer;

             tempContainer = getParent();
             while (! (tempContainer instanceof Frame) )
             {
                tempContainer = tempContainer.getParent();
             }
             parentFrame = (Frame) tempContainer;
          }

          public static void main(String argv[])
          {
             AppletFrame.startApplet("DialogMoveTest", "Dialog Move Test", argv);
          }
      }


      class TestDialog extends Dialog
      {
          private TextArea textArea;
          private final String GET_PARENT = "Get Parent";
          private final String MOVE = "Move";

          public TestDialog(Frame parent, String title, boolean modal)
          {
             super(parent, title, modal);

             setLayout( new BorderLayout() );
             
             // setup button panel
             Panel temp = new Panel();
             temp.add( new Button(GET_PARENT) );
             temp.add( new Button(MOVE) );
             add( "North", temp );
             add( "Center", textArea = new TextArea() );
             resize(400, 400);
          }

          public boolean handleEvent(Event evt)
          {
             if (evt.id == Event.WINDOW_DESTROY)
             {
                dispose();
                return true;
             }
             else
                return super.handleEvent(evt);
          }

          public boolean action(Event evt, Object obj)
          {
             if (evt.target instanceof Button)
             {
                String label = (String) obj;
             
                if( label.equals(GET_PARENT) )
                {
                   textArea.appendText( "Parent: " + getParent().toString() + "\\n" );
                   textArea.appendText( "Parent Location: " +
                                        getParent().location().toString() +
                                        "\\n" );
                }
                else if ( label.equals(MOVE) )
                {
                   move(100, 100);
                }
                else
                {
                   return false;
                }
                
                // print out location
                textArea.appendText( "Location: " + location().toString() + "\\n" );
                return true;
                
             }
             else
                return super.action(evt, obj);
          }
      }



      /* Generic Applet to Application Frame
       * @(#)AppletFrame.java 1.4 12/02/95 15:28:07
       * @author Kevin A. Smith
       */

      import java.awt.Frame;
      import java.awt.Event;
      import java.awt.Dimension;
      import java.applet.Applet;

      // Applet to Application Frame window
      class AppletFrame extends Frame
      {

          public static void startApplet(String className,
                                         String title,
                                         String args[])
          {
             // local variables
             Applet a;
             Dimension appletSize;

             try
             {
                // create an instance of your applet class
                a = (Applet) Class.forName(className).newInstance();
             }
             catch (ClassNotFoundException e) { return; }
             catch (InstantiationException e) { return; }
             catch (IllegalAccessException e) { return; }

             // initialize the applet
             a.init();
             a.start();
        
             // create new application frame window
             AppletFrame f = new AppletFrame(title);
        
             // add applet to frame window
             f.add("Center", a);
        
             // resize frame window to fit applet
             // assumes that the applet sets its own size
             // otherwise, you should set a specific size here.
             appletSize = a.size();
             f.pack();
             f.resize(appletSize);

             // show the window
             f.show();
        
          } // end startApplet()
        
        
          // constructor needed to pass window title to class Frame
          public AppletFrame(String name)
          {
             // call java.awt.Frame(String) constructor
             super(name);
          }

          // needed to allow window close
          public boolean handleEvent(Event e)
          {
             // Window Destroy event
             if (e.id == Event.WINDOW_DESTROY)
             {
                // exit the program
                System.exit(0);
                return true;
             }
             
             // it's good form to let the super class look at any
             // unhandled events
             return super.handleEvent(e);

          } // end handleEvent()

      } // end class AppletFrame






        Attachments

          Activity

            People

            Assignee:
            jeff Jeff Dinkins
            Reporter:
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: