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

JToolBar not listening to FocusListener methods

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P2 P2
    • None
    • 1.4.0
    • 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());
          }
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: