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

Bidi, JDK1.4.0-bb32, Mnemonics Font Metrics problem

    Details

      Description

      Name: jbT81659 Date: 09/27/2000

      OS: Win98-Arabic/Hebrew
      JDK:1.4.0-Beta32

      This bug applies to other Swing components like JButton, JCheckBox....
      Mnemonics underscore fails to display under arabic characters that
      extends below the text base line causing the Mnemonics underscore to
      overlap the designated character

      To reproduce bug:
      1- Compile and run the following code
      2- Observe the Mnemonics underscore under Arabic chracters.
      3- Verify that underscore overlaps characters that extends below the text base line

      --------Code-----------

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

      public class mnemonics extends JApplet
      {
          public void init()
          {
              JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
              frame.setJMenuBar(new jMenuX());
              frame.setSize(500, 400);
              frame.setVisible(true);
          }
          public static void main(String[] argv)
          {
              jMenuX example = new jMenuX();
              example.pane = new JTextPane();
              example.pane.setPreferredSize(new Dimension(250, 300));
              example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED));
              JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
              frame.getContentPane().add(example, BorderLayout.NORTH);
              frame.getContentPane().add(example.pane, BorderLayout.SOUTH);
              frame.setFont(new Font("Lucida Sans Regular", Font.PLAIN,8));
              frame.setSize(500, 400);
              frame.setVisible(true);
              frame.addWindowListener( new WindowAdapter()
              {
                 public void windowClosing( WindowEvent e)
                 {
                    System.exit(0);
                 }
              });
           }
      }
      class jMenuX extends JMenuBar implements ActionListener
      {
            public JTextPane pane;

         String[] fileItemsEnglish = new String[]
         {
             "\u0041\u0042\u0043\u0044",
             "\u0061\u0062\u0063\u0064",
             "\u0065\u0066\u0067\u0068",
             "\u0030\u0031\u0032\u0033"
         };


         String[] fileItemsArabic = new String[]
         {
             "\u062c\u062f\u064a\u062f",
             "\u0641\u062a\u062d",
             "\u062d\u0641\u0638",
             "\u062e\u0631\u0648\u062c"
         };


         String[] fileItemsHebrew = new String[]
         {
             "\u05d7\u05d3\u05e9",
             "\u05e4\u05ea\u05d9\u05d7\u05d4",
             "\u05e9\u05de\u05d9\u05e8\u05d4",
             "\u05d9\u05e6\u05d9\u05d0\u05d4"
         };

         String[] fileItemsBidi = new String[]
         {
             "\u062c\u062f\u064a\u062f\u0020\u05d7\u05d3\u05e9",
             "\u0641\u062a\u062d\u0020\u05e4\u05ea\u05d9\u05d7\u05d4",
             "\u062d\u0641\u0638\u0020\u05e9\u05de\u05d9\u05e8\u05d4",
             "\u05d9\u05e6\u05d9\u05d0\u05d4\u0020\u062e\u0631\u0648\u062c"
         };

         char[] fileShortcutsEnglish = { '\u0041','\u0061','\u0065','\u0030' };
         char[] fileShortcutsArabic = { '\u062c','\u0641','\u062d','\u062e' };
         char[] fileShortcutsHebrew = { '\u05d7','\u05e4','\u05e9','\u05d9' };
         char[] fileShortcutsBidi = { '\u062c','\u0641','\u05de','\u05d9' };

         public jMenuX()
         {

            JMenu fileMenu = new JMenu("English");
            JMenu Menu2 = new JMenu("Menu2 \u0639\u0631\u0628\u064a");
            JMenu Menu3 = new JMenu("Menu3 \u05e2\u05d1\u05e8\u05d9\u05ea");
            JMenu Menu4 = new JMenu("Menu4 Bidi\u05e2\u05d1\u05e8\u05d9\u05ea\u0020\u0639\u0631\u0628\u064a");
            fileMenu.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
            Menu2.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
            Menu3.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
            Menu4.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
            fileMenu.setMnemonic('G');
            Menu2.setMnemonic('\u0639');
            Menu3.setMnemonic('\u05e2');
            Menu4.setMnemonic('\u05d1');


            for (int i=0; i < fileItemsEnglish.length; i++)
            {
                JMenuItem item = new JMenuItem(fileItemsEnglish[i]);
                item.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
                item.setMnemonic(fileShortcutsEnglish[i]);
                item.addActionListener(this);
                fileMenu.add(item);
            }

            for (int i=0; i < fileItemsArabic.length; i++)
            {
                JMenuItem item = new JMenuItem(fileItemsArabic[i]);
                item.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
                item.setMnemonic(fileShortcutsArabic[i]);
                item.addActionListener(this);
                Menu2.add(item);
            }


            for (int i=0; i < fileItemsHebrew.length; i++)
            {
                JMenuItem item = new JMenuItem(fileItemsHebrew[i]);
                item.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
                item.setMnemonic(fileShortcutsHebrew[i]);
                item.addActionListener(this);
                Menu3.add(item);
            }
            for (int i=0; i < fileItemsBidi.length; i++)
            {
                JMenuItem item = new JMenuItem(fileItemsBidi[i]);
                item.setFont(new Font("Lucida Sans Regular",Font.PLAIN,14));
                item.setMnemonic(fileShortcutsBidi[i]);
                item.addActionListener(this);
                Menu4.add(item);
            }

      this.setPreferredSize( new Dimension(400, 40));
            add(fileMenu);
            add(Menu2);
            add(Menu3);
            add(Menu4);
           }

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

           }
      }


      WorkAround:
      ======================================================================
      ###@###.### 10/22/04 01:51 GMT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                idk Igor Kushnirskiy (Inactive)
                Reporter:
                jbenavrasunw Jonathan Benavraham (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: