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(); } } }
|