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

LayoutStyle.getPreferredGap() - IAE is expected but not thrown

    Details

    • Subcomponent:
    • Resolved In Build:
      b06
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        From LayoutStyle.getPreferredGap() spec:
        "Throws:
        IllegalArgumentException - if position is not one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST"

        But IllegalArgumentException not thrown! See mini-test (updated!):


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

        import static javax.swing.LayoutStyle.ComponentPlacement.RELATED;
        import static javax.swing.SwingConstants.*;

        public class GetPreferredGapTest {

            public static void main(String[] args) throws UnsupportedLookAndFeelException, ClassNotFoundException, IllegalAccessException, InstantiationException {

                for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
                    UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                    LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
                    System.out.println("LookAndFeel: " + lookAndFeel.getName());

                    LayoutStyle layoutStyle = LayoutStyle.getInstance();
                    System.out.println("LayoutStyle: " + layoutStyle);

                    for (int position : new int[]{NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST, 123, -456}) {
                        try {
                            layoutStyle.getPreferredGap(new JComponent() {}, new JComponent() {}, RELATED, position, new Container());
                            System.out.println("getPreferredGap(): Position " + position + " - No IAE!");
                        } catch (IllegalArgumentException e) {
                            System.out.println("getPreferredGap(): Position " + position + " - IAE!");
                        }
                    }

                    System.out.println();
                }
            }

        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rupashka Pavel Porvatov (Inactive)
                  Reporter:
                  alfedoro Alexey Fedorov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: