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

Changing panels in a frame with BorderLayout fails on win95

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_95

      Description

      Running the java application below, which creates a frame and then toggles
      between two panels being displayed in the frame depending on the button
      pressed. The Frame layout is set to BorderLayout and it would appear that
      on Win95 the refresh doesn't seem to take place.

      It works on Solaris 2.x but fails with Win95. On Win95, it seems to stick on
      the first panel while on Solaris 2.x the displayed panels do alternate
      correctly.

      (I haven't tried this on a Mac to see if this is also an issue.)

      Both version where tested using JDK 1.0.2

      // ==================================================================
      // Framer.java
      // ==================================================================

      import java.awt.*;

      public class Fails extends Frame
      {
          Panel p1, p2;
          Button b1, b2;

          public static void main(String argv[])
          {
              new Fails();
          }

          Fails()
          {
              p1 = new Panel();
              p2 = new Panel();
              b1 = new Button("PANEL 1");
              b2 = new Button("PANEL 2");

              p1.setLayout( new BorderLayout() );
              p2.setLayout( new BorderLayout() );

              p1.add("Center", b1);
              p2.add("Center", b2);

              this.setLayout( new BorderLayout() );
              this.add("Center", p1);

              this.resize(500,500);
              this.show();
          }

          public boolean handleEvent(Event e)
          {
              if ( e.target == b1 && e.id == Event.ACTION_EVENT )
              {
                  System.out.println("Button 1 Pressed");
                  this.add("Center", p2);
                  this.show();
              }
              else if ( e.target == b2 && e.id == Event.ACTION_EVENT )
              {
                  System.out.println("Button 2 Pressed");
                  this.add("Center", p1);
                  this.show();
              }
              else if ( e.id == Event.WINDOW_DESTROY )
              {
                  dispose();
                  System.exit(0);
                  return true;
              }

              return false;
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ssisunw Ssi Ssi (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: