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

When a JInternalFrame is activated, focus is not transferred to its children.

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic, x86
    • OS:
      generic, solaris_2.5, windows_95, windows_nt

      Description

      1. Compile and Run the attached example.
      2. Create two internal frames using File:New Menu.
      3. Type text in the text area of the selected IFrame.
      4. Single click in the text area or title bar of the unselected frame.
         The IFrame appears to be selected however if more text is typed
         it goes to text area of the formerly selected Iframe.

      In other words single click inside an unselected frame selects it but
      the keyboard focus is not adjusted accordingly.

      sandip.chitale@Eng 1998-02-05


      // Example
      import java.awt.*;
      import java.awt.event.*;
      import com.sun.java.swing.*;

      public
      class SwingTest
      extends JFrame
      implements ActionListener
      {
        private JMenuItem mNew;
        private JMenuItem mExit;
        
        public
        SwingTest()
        {
          super("SwingTest");
          setBackground(SystemColor.control);
          
          JMenuBar mb = new JMenuBar();
          JMenu mFile = new JMenu("File");
          mNew = new JMenuItem("New");
          mNew.addActionListener(this);
          mFile.add(mNew);
          mExit = new JMenuItem("Exit");
          mExit.addActionListener(this);
          mFile.add(mExit);
          mb.add(mFile);
          setJMenuBar(mb);

          setContentPane(new JDesktopPane());
          Container cp = getContentPane();
          

          JDesktopPane dp = new JDesktopPane();
          dp.setOpaque(true);
          cp.add(dp, BorderLayout.EAST);

          getContentPane().setBackground(SystemColor.control);
          setSize(800, 600);
          setVisible(true);
        }
        
        private int iFrameCount = 0;

        public
        void
        actionPerformed(ActionEvent ae)
        {
          if (ae.getSource() == mNew)
          {
          
            JInternalFrame iFrame = new JInternalFrame("Internal Frame - " + iFrameCount, true, true, true, true);
            
            Container cp = iFrame.getContentPane();
            cp.setLayout(new BorderLayout());
            final JTextArea o = new JTextArea();
            cp.add(o, BorderLayout.CENTER);
            JButton b = new JButton("" + iFrameCount);
            b.setToolTipText("Button " + iFrameCount);
            cp.add(b, BorderLayout.SOUTH);
            b.addActionListener( new ActionListener()
                                  {
                                    public
                                    void
                                    actionPerformed(ActionEvent ae)
                                    {
                                      o.append(ae.getActionCommand() + "\n");
                                    }
                                  }
                                );
            ///*
            JLabel l = new JLabel("Label " + iFrameCount);
            cp.add(l, BorderLayout.NORTH);
            l.addMouseListener(new MouseListener()
            {
             public void mouseClicked(MouseEvent e) {};
             public void mousePressed(MouseEvent e) {};
             public void mouseReleased(MouseEvent e) {};
             public void mouseEntered(MouseEvent e) {};
             public void mouseExited(MouseEvent e) {};
            }
            );
            //*/
            iFrame.setBounds(iFrameCount * 20, iFrameCount * 40, 200, 200);
            getContentPane().add(iFrame);
            try {
              iFrame.setSelected(true);
            } catch (Exception e)
            {
              System.out.println(e);
            }
            iFrameCount++;
            iFrameCount %= 10;
            return;
          }
          
          if (ae.getSource() == mExit)
          {
            System.exit(0);
            return;
          }
        }
        
        
        public
        static
        void
        main(String args[])
        {
          new SwingTest();
        }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hgajewsksunw Hania Gajewska (Inactive)
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: