JToolBar not listening to FocusListener methods

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P2
    • None
    • Affects Version/s: 1.4.0
    • Component/s: client-libs

      Both methods focusGained and focusLost methods failed reporting when JToolBar was in focus.

      Code snippet:
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class FrameDemo extends JFrame implements FocusListener {
          public FrameDemo() {
              setSize(300, 300);
              
              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });
              
              //adding JToolBar
              JToolBar toolBar = new JToolBar();
              toolBar.addFocusListener(this);
              
              getContentPane().add(toolBar, BorderLayout.CENTER);
          }
          public static void main(String s[]) {
            FrameDemo fd = new FrameDemo();
            
            fd.pack();
            fd.setVisible(true);
          }
          
          public void focusGained(FocusEvent e) {
            System.out.println(e.getComponent());
          }
          
          public void focusLost(FocusEvent e) {
            System.out.println(e.getComponent());
          }
      }

            Assignee:
            Hania Gajewska (Inactive)
            Reporter:
            Sridhar Raman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: