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

JComboBox drop-down list orientation is changed after the L&F is changed

    Details

    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      generic
    • OS:
      generic

      Description

      When the JComboBox is set to Right-To-Left orientation, the drop-down list has the scroll bar on the left side and the strings are on the right side which is corect. After other L&F is selected, the scroll bar is changed to the right side. After the original L&F is selected again, the scroll bar is still on the right side.

      This is not a regression.

      How to reproduce:
      1. Compile and run JComboBoxTest.java with jdk1.4.2-b16.
      2. bring up the drop down list. The scroll bar is on the left side.
         which is correct. The text is on the right side bug with left alignment
         (the alignment problem is filed throught bug 4802640)
      3. From the L&F menu select other L&F.
      4. From the L&F menu go back to the first L&F(Metal) which is the default one for step1. The scroll bar is on the right side, not the left side.

      -------------------------------------------------------------------

      This bug is similiar to what I have also found as well. I tired using the method setComponentOrentation and or applyComponentOrientation to set the orientation of the combobox RTL, but nothing seems to happen. However, when I use the setEditable method and set it to true, the combobox's drop down button then moves from the right side to the left. Comment and un-comment out the setEditable in the code below to see this:

      ------------------------------------------------------------------
      import java.awt.*;
      import javax.swing.*;

      public class JComboBoxTest {

          public static void main(String[] args) {
              String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
              JComboBox b = new JComboBox(petStrings);
              b.setEditable(true);
              b.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.getContentPane().add(b);
              f.pack();
              f.setVisible(true);
          }
      }
      -------------------------------------------------------------------

      ###@###.### 2004-02-27

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lzhanorcl Lichun Zhan (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: