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

Button stuck as depressed when disabled in mouseReleased

    XMLWordPrintable

Details

    • sparc
    • solaris_2.5.1

    Description



      Name: clC74495 Date: 06/24/98


      Carlos.Lucasius@Canada (June 24, 1998):
      This bug was initially reported for JDK1.1.5, but it
      can also be reproduced in JDK1.1.6 and JDK1.2beta4.

      Description follows:

      Compile following java as test.java.
      Run in appletviewer.
      Select "Disable Me" button
      (Note button is frozen in depressed state.)
      Select "Enable Him" button.
      (Note that button is visually depressed initially
      and after mouse moves over button, visually not
      depressed after mouse moves off of button --
      even though no mouse button is pressed.)

      This happens only on Solaris (appletviewer and
      Netscape 4.05 w/ Java 1.1 Plug-in). Does not
      happen on NT (IE or NS).

      import java.applet.Applet;
      import java.awt.event.*;
      import java.awt.*;
       
      class StippleStencil
          implements ActionListener
      {
          private Component component;
          private boolean state;
          private Component focusField;
          public StippleStencil(
              Component component,
              boolean state,
              Component focusField
              )
          {
          this.component = component;
          this.state = state;
          this.focusField = focusField;
          }
          public void actionPerformed(
              ActionEvent event
              )
          {
          this.component.setEnabled(this.state);
          this.focusField.requestFocus();
          return;
          }
      }
       
      class Mickey implements MouseListener
      {
          private Component theComponent;
          private Component focusField;
          public Mickey(
              Component theComponent,
              Component focusField
              )
          {
          this.theComponent = theComponent;
          this.focusField = focusField;
          }
          public void mouseClicked(
              MouseEvent event
              )
          {
          // this.theComponent.setEnabled(false);
          // this.focusField.requestFocus();
          return;
          }
          public void mousePressed(
              MouseEvent event
              )
          {
          return;
          }
          public void mouseReleased(
              MouseEvent event
              )
          {
          this.theComponent.setEnabled(false);
          this.focusField.requestFocus();
          return;
          }
          public void mouseEntered(
              MouseEvent event
              )
          {
          return;
          }
          public void mouseExited(
              MouseEvent event
              )
          {
          return;
          }
      }
       
      public class test extends Applet
      {
       
          public test()
          {
       
          this.setLayout(new BorderLayout(10, 0));
       
          Component field = new TextField("ABCDEFG", 20);
          this.add("North", field);
          this.add("Center", new Panel());
       
          Button button;
          button = new Button("Disable Me");
          // button.addActionListener(new StippleStencil(button, false, field));
          button.addMouseListener(new Mickey(button, field));
          this.add("West", button);
       
          Button button2;
          button2 = new Button("Enable Him");
          button2.addActionListener(new StippleStencil(button, true, field));
          this.add("East", button2);
       
          this.doLayout();
          this.setVisible(true);
          }
      }



      <html>
      <head>
      <title>test</title>
      </head>

      <body>
      <applet code="test.class" width=500 height=500>
      </applet>
      </body>
      </html>

      (Review ID: 34160)
      ======================================================================

      Attachments

        Activity

          People

            jmelvin James Melvin (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: