-
Bug
-
Resolution: Fixed
-
P2
-
7
-
b06
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2212230 | 8 | Pavel Porvatov | P2 | Closed | Fixed | b01 |
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();
}
}
}
"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();
}
}
}
- backported by
-
JDK-2212230 LayoutStyle.getPreferredGap() - IAE is expected but not thrown
-
- Closed
-