• Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.0
    • client-libs
    • sparc
    • solaris_2.4

      When using the appletviewer, layout of widgets within
      an applet changes unexpectedly when the appletviewer window
      is closed and reopened.
      Following are html and .java code to put up a single
      button in an applet.
      0) Compile the code
      1) bring up the applet in appletviewer. The button is
         in the center of the top of the window
      2) close the appletviewer window and reopen it.
         the button is now in the upper-left corner. This
         is a suprise.
      3) resize the viewer by picking up and dragging any corner
         of the appletviewer frame. The button moves back to
         the top center.
         
      ---showbutton.html-----------
      <html>
      <body>
      <hr>
      <applet code="ShowButton.class" height=200 width=500>
      </applet>
      <hr>
      </body>
      </html>
      -----ShowButton.java-------------
      import java.awt.*;
      import java.applet.Applet;
      import java.applet.AppletContext;

      class helloButton extends Button {
          private Applet m;
          private AppletContext myApp;
          private int n;

          public helloButton( Applet me ){
      super( "Hello");
      m = me;
      myApp = me.getAppletContext();
      n = 0;
          }

          public boolean handleEvent( Event ignore ){
      Rectangle r = m.bounds();
      myApp.showStatus("Button pushed "+(++n)+" times: size is "+r.width+" w. by "+r.height+" h.");
      return true;
          }

      }

      public class ShowButton extends java.applet.Applet {
          private static final int
      height = 100,
      width = 200;
          private Button b;

          public void init(){
      resize( width, height );
      setForeground( Color.green );
      setLayout( new FlowLayout() );
      b = new helloButton( this );
          }
          public void paint( Graphics g ){
      Rectangle r = bounds();
      g.drawRect( 0, 0, r.width-1, r.height-1 );
          }
          public void start(){
      add( b );
      validate();
          }
          public void stop(){
      remove( b );
          }

      }

            sshaiosunw Sami Shaio (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: