Drop platform-specific import
This makes the code compile with other compilers; I'm not
sure about the runtime behavior so I used reflection when
possible to preserve the current behavior if available.
To mimic the exact runtime behavior you probably want to
use GridBagLayout instead of BoxLayout.
Change-Id: Ieb79c53f9b49157769f306c62e9f9225379b5be2
diff --git a/chartlib/src/test/java/AnimatedComponentVisualTests.java b/chartlib/src/test/java/AnimatedComponentVisualTests.java
index 68cb79b..837e3cf 100644
--- a/chartlib/src/test/java/AnimatedComponentVisualTests.java
+++ b/chartlib/src/test/java/AnimatedComponentVisualTests.java
@@ -23,6 +23,7 @@
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
@@ -43,8 +44,6 @@
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import sun.awt.VerticalBagLayout;
-
public class AnimatedComponentVisualTests extends JDialog {
private List<AnimatedComponent> mComponents = new LinkedList<AnimatedComponent>();
@@ -145,7 +144,15 @@
panel.setLayout(new BorderLayout());
mComponents.add(animated);
panel.add(animated, BorderLayout.CENTER);
- JPanel controls = new JPanel(new VerticalBagLayout());
+
+ JPanel controls = new JPanel();
+ LayoutManager manager;
+ try {
+ manager = (LayoutManager) Class.forName("sun.awt.VerticalBagLayout").newInstance();
+ } catch (Exception e) {
+ manager = new BoxLayout(controls, BoxLayout.Y_AXIS);
+ }
+ controls.setLayout(manager);
controls.setPreferredSize(new Dimension(300, 800));
panel.add(controls, BorderLayout.WEST);
return controls;