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

The behavior of java.awt.List in jdk5 should be the same to that in JDK6,7 and 8

XMLWordPrintable

    • b14
    • b01
    • generic
    • windows



        In JDK5u71, When a program lays out java.awt.List by using FlowLayout,
        although there is no space of preferred size in right side,
        the List is placed at right side.

        In JDK6u81, 7u65 and 8u11, the List is placed at next row.

        TEST CASE
        -----------
        Test case is as follows.

        --- ListTest.java --->
        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;

        public class ListTest extends Frame implements ActionListener {

            Button button = new Button("List.getPreferredSize()");
            List list = new List(5);
            Label label = new Label();

            public static void main(String ar[]){
                Frame f = new ListTest();
                f.setSize(350,350);
                f.setVisible(true);
            }

            ListTest(){
                addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                        System.exit(0);
                    }
                });

                setLayout(new FlowLayout());
                button.addActionListener(this);
                add(button);
                list.add("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
                add(list);
            }

            public void actionPerformed(ActionEvent e){
                Dimension dim = list.getPreferredSize();
                button.setBackground(Color. YELLOW);
                button.setLabel("Width:" + Double.toString(dim.getWidth()) + "
        Height:" +Double.toString( dim.getHeight()));
            }
        }
        <---


        REPRODUCTION INSTRUCTIONS
        -------------------------------
        Compile ListTest.java and run "java ListTest"

        EXPECTED Result
        ----------------
        List appears under "List.getPreferredSize() " button.

        ACTUAL Result
        -----------------
        List appears at the right side of "List.getPreferredSize() " button.

         

              aivanov Alexey Ivanov
              shadowbug Shadow Bug
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: