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

More JButton problems (J2SDK(SE)1.3RA) -- in Metal L&F

XMLWordPrintable

    • kestrel
    • generic, x86
    • generic, windows_nt



      Name: krT82822 Date: 10/12/99


      10/12/99 eval1127@eng -- believe this one is an existing bug, and not new to kestrel, but could NOT find dupe.
      May be related to 4251772 (and thus fixed in final kestrel?), or 4251774 (still open since 1.2.2, but not really what we're seeing, since focus IS transferred when current
      button is disabled)

      Filing new bug, just to make sure this issue will get resolved.

      -----------------

      With the Java L&F, JButtons misbehave as follows.

      When the button is clicked, it is disabled, then re-enabled. After you click a button, you can't click it again unless you first move the mouse off of the button. You can leave the mouse on it and type its shortcut, but it won't click unless the mouse leaves it.


      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class Test2 extends JFrame implements ActionListener
      {
      public Test2()
      {
      super("test");
      setBounds(new Rectangle(100,100,300,100));
      JButton imaButton = new JButton("One");
      imaButton.setMnemonic('o');
      imaButton.addActionListener(this);
      JButton imaButton2 = new JButton("Two");
      imaButton2.setMnemonic('w');
      imaButton2.addActionListener(this);
      JButton imaButton3 = new JButton("Three");
      imaButton3.setMnemonic('t');
      imaButton3.addActionListener(this);
      getContentPane().setLayout(new FlowLayout());
      getContentPane().add(imaButton);
      getContentPane().add(imaButton2);
      getContentPane().add(imaButton3);
      addWindowListener(new FrameListener());
      setVisible(true);
      }

      public static void main(String[] args)
      {
      try {
      Test2 test = new Test2();
      }
      catch (Exception ex) {
      ex.printStackTrace();
      }
      }

      public void actionPerformed(ActionEvent e)
      {
      JButton source = (JButton)e.getSource();
      System.out.println(source.getText());
      source.setEnabled(false);
      source.setEnabled(true);
      }

      private class FrameListener extends WindowAdapter {
      public FrameListener(){}

      public void windowClosing(WindowEvent e) {
      System.exit(0);
      }

      }


      }
      (Review ID: 96434)
      ======================================================================

      Name: krT82822 Date: 10/13/99


      10/13/99 eval1127@eng -- dupe of 4280446

      This is the same code for bug with review id 96395. As I was
      testing this code segment I noticed a different problem.

      Move the main frame to the center of the screen and keep hitting
      "Add" as windows pop up in the upper left corner. The add
      button will only work for one click. After this you will need to select somewhere else before the button will work again.

      This is not the case in 1.2.2
      -------------------
      CODE:

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      final public class SunTest16 extends JFrame {

      int count = 0;

      public SunTest16() {
      super("Bug");
      Container contentPane = getContentPane();
      contentPane.setLayout(new FlowLayout());

      JButton b = new JButton("Add");
      b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      MyClass o = new MyClass(++count);
      o.setSize(200,200);
      o.show();
      }
      });
      contentPane.add(b);

      b = new JButton("GC");
      b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      System.gc();
      }
      });
      contentPane.add(b);
      addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
      dispose();
      System.exit(0);
      }
      });
      }
      public static void main(String[] args) {
      SunTest16 s = new SunTest16();
      s.setSize(400,300);
      s.setLocaiton(300,300); // [added -- to keep button unobscured by the opened dialogs]
      s.show();
      }
      public static class MyClass extends JFrame {
      JMenuBar menubar;
      int count;

      public MyClass(int count) {
      super("Frame: " + count);
      this.count = count;

      Container contentPane = getContentPane();
      contentPane.setLayout(new BorderLayout());

      menubar = new JMenuBar();
      JMenu m = new JMenu("Test");
      Action a = new AbstractAction("Action") {
      public void actionPerformed(ActionEvent e) {
      System.out.println("Action");
      }
      };

      m.add(a);
      menubar.add(m);

      contentPane.add(menubar,BorderLayout.NORTH);

      addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
      //System.out.println("Closing");
      dispose();
      }
      });
      }
      public void finalize() throws Throwable {
      System.out.println("Finalizing frame: " + count);
      super.finalize();
      }
      public void dispose() {
      //System.out.println("Disposing frame: " + count);
      super.dispose();
      }
      }
      }
      (Review ID: 96396)
      ======================================================================

            jeff Jeff Dinkins
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: