1 /* |
1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
26 * @bug 7071166 |
26 * @bug 7071166 |
27 * @summary LayoutStyle.getPreferredGap() - IAE is expected but not thrown |
27 * @summary LayoutStyle.getPreferredGap() - IAE is expected but not thrown |
28 * @author Pavel Porvatov |
28 * @author Pavel Porvatov |
29 */ |
29 */ |
30 |
30 |
31 import javax.swing.*; |
31 import java.awt.Container; |
32 import static javax.swing.SwingConstants.*; |
32 |
33 import java.awt.*; |
33 import javax.swing.JButton; |
|
34 import javax.swing.LayoutStyle; |
|
35 import javax.swing.SwingUtilities; |
|
36 import javax.swing.UIManager; |
|
37 import javax.swing.UnsupportedLookAndFeelException; |
|
38 |
|
39 import static javax.swing.SwingConstants.EAST; |
|
40 import static javax.swing.SwingConstants.NORTH; |
|
41 import static javax.swing.SwingConstants.NORTH_EAST; |
|
42 import static javax.swing.SwingConstants.NORTH_WEST; |
|
43 import static javax.swing.SwingConstants.SOUTH; |
|
44 import static javax.swing.SwingConstants.SOUTH_EAST; |
|
45 import static javax.swing.SwingConstants.SOUTH_WEST; |
|
46 import static javax.swing.SwingConstants.WEST; |
34 |
47 |
35 public class bug7071166 { |
48 public class bug7071166 { |
36 private static final int[] POSITIONS = {NORTH, EAST, SOUTH, WEST, // valid positions |
49 private static final int[] POSITIONS = {NORTH, EAST, SOUTH, WEST, // valid positions |
37 NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, 123, -456}; // invalid positions |
50 NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, 123, -456}; // invalid positions |
38 |
51 |
39 public static void main(String[] args) throws Exception { |
52 public static void main(String[] args) throws Exception { |
40 for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) { |
53 for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) { |
41 UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); |
54 try { |
42 |
55 UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); |
|
56 } catch (final UnsupportedLookAndFeelException ignored) { |
|
57 continue; |
|
58 } |
43 System.out.println("LookAndFeel: " + lookAndFeelInfo.getName()); |
59 System.out.println("LookAndFeel: " + lookAndFeelInfo.getName()); |
44 |
60 |
45 SwingUtilities.invokeAndWait(new Runnable() { |
61 SwingUtilities.invokeAndWait(new Runnable() { |
46 public void run() { |
62 public void run() { |
47 LayoutStyle layoutStyle = LayoutStyle.getInstance(); |
63 LayoutStyle layoutStyle = LayoutStyle.getInstance(); |