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

Linux:JCheckBoxMenuItem does not respond to Keyboard actions( Up/Down arrows/Ret

    XMLWordPrintable

    Details

      Description



      Name: jbT81659 Date: 08/15/2000

      RedHat Linux6.2 (KDE), Intel machine

      JCheckBoxMenuItem does not respond to actions from the keyboard like using up/down arrows to move
      between items. Using Spacebar to activate or disactivate a JCheckBoxMenuItem is broken.

      To reproduce bug:
      1- Compile and run the following code.
      2- Use the mouse to open Menu.
      3- Use mouse to move up and down the choices
      4- Click any JCheckBoxMenuItem and note that is checked
      5- click again the same JCheckBoxMenuItem and note that it is unchecked
      6- Try using the keyboard arrows to move up and down
      7- Note that it can not be done
      8- Click Spacebar and note that either Checking or Unchecking the JCheckBoxMenuItem did not happen.

      -------------CODE-------------
      /* Copyright (c) Sun Microsystems 1998

      $Header: /home/sun/src/JDK1.2/jCheckBoxMenuItem.java,v 1.13 2000/04/25 11:17:18 isam Exp $

      */

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

      public class jCheckBoxMenuItem extends JApplet
      {
        public void init()
        {
                      
              jCheckBoxMenuItem1 example = new jCheckBoxMenuItem1 ();
              example.pane = new JTextPane();
              example.pane.setPreferredSize(new Dimension(250, 250));
              example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED));
              getContentPane().add(example.menuBar, BorderLayout.NORTH);
              getContentPane().add(example.pane, BorderLayout.CENTER);

        }

              public static void main(String[] argv)
              {
                      jCheckBoxMenuItem1 example = new jCheckBoxMenuItem1 ();
                      example.pane = new JTextPane();
                      example.pane.setPreferredSize(new Dimension(250, 250));
                      example.pane.setBorder(new BevelBorder(BevelBorder.RAISED));
                      JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
                      frame.getContentPane().add(example.menuBar, BorderLayout.NORTH);
                      frame.getContentPane().add(example.pane, BorderLayout.CENTER);
                      frame.pack();
                      frame.setVisible(true);
              frame.addWindowListener( new WindowAdapter()
              {
                   public void windowClosing( WindowEvent e)
                   {
                       System.exit(0);
                   }
              });

              }
      }

      class jCheckBoxMenuItem1 extends JPanel implements ActionListener
      {
              public JTextPane pane;
              public JMenuBar menuBar;
              public JToolBar toolBar;

              public jCheckBoxMenuItem1()
              {
                      super(true);
              TitledBorder titled;
              titled = BorderFactory.createTitledBorder("\u0645\u062b\u0627\u0644\u0020\u05d3\u05d2\u05de\u05d4");
              titled.setTitleFont( new Font("Lucida Sans Regular", Font.PLAIN,9));
                      menuBar = new JMenuBar();
              menuBar.setBorder(titled);
                      JMenu justifyMenu = new JMenu();
                      justifyMenu.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16));
      justifyMenu.setText("\u0645\u062b\u0627\u0644\u0020\u05d3\u05d2\u05de\u05d4");
                      justifyMenu.setMnemonic('J');

                      JCheckBoxMenuItem leftJustify = new JCheckBoxMenuItem("\u0647\u0630\u0647\u0020\u0633\u0646\u0629\u0020\u0661\u0669\u0665\u0668\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0020\u0031\u0039\u0035\u0038");
              leftJustify.setBorder(titled);
                      leftJustify.setHorizontalTextPosition(JMenuItem.LEFT);
                      leftJustify.setMnemonic('L');
                      leftJustify.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16));
                      leftJustify.addActionListener(this);

                      
                      JCheckBoxMenuItem rightJustify = new JCheckBoxMenuItem("\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038");
              rightJustify.setBorder(titled);
                      rightJustify.setHorizontalTextPosition(JMenuItem.LEFT);
                      rightJustify.setMnemonic('R');
                      rightJustify.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16));
                      rightJustify.addActionListener(this);

                      JCheckBoxMenuItem centerJustify = new JCheckBoxMenuItem("\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
              centerJustify.setBorder(titled);
                      centerJustify.setHorizontalTextPosition(JMenuItem.LEFT);
                      centerJustify.setMnemonic('C');
                      centerJustify.addActionListener(this);
                      centerJustify.setFont(new Font("Lucida Sans Regular",Font.PLAIN,16));

                      justifyMenu.add(leftJustify);
                      justifyMenu.add(rightJustify);
                      justifyMenu.add(centerJustify);

                      menuBar.add(justifyMenu);
                      Font sammy = new Font("Lucida Sans Regular", Font.PLAIN, 8);
              }
              public void actionPerformed(ActionEvent e)
              {
                      try
                      {
                          pane.getStyledDocument().insertString(0 , "Action ["+e.getActionCommand()+"] performed!\n", null);
                      }
                      catch (Exception ex) {;}
              }
      }


      WorkAround:
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jbenavrasunw Jonathan Benavraham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: