01: /*
02: * $Id: JXStatusBarTest.java,v 1.1 2007/02/08 05:12:43 rbair Exp $
03: *
04: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
05: * Santa Clara, California 95054, U.S.A. All rights reserved.
06: */
07:
08: package org.jdesktop.swingx;
09:
10: import java.awt.Dimension;
11: import javax.swing.JFrame;
12: import javax.swing.JLabel;
13: import javax.swing.LookAndFeel;
14: import javax.swing.UIManager;
15:
16: /**
17: *
18: * @author rbair
19: */
20: public class JXStatusBarTest extends junit.framework.TestCase {
21:
22: /**
23: * This test ensures that after the LAF is switched, the Border and
24: * LayoutManager are still in valid states.
25: */
26: public void testLAFSwitch() throws Exception {
27: //create a status bar with a single child, a label.
28: //ensure that after switching look and feels, the layout manager
29: //on the status bar still references the label
30: JXStatusBar bar = new JXStatusBar();
31: JLabel label = new JLabel("Hello");
32: bar.add(label);
33: Dimension dim = bar.getLayout().preferredLayoutSize(bar);
34: toggleLAF();
35: toggleLAF();
36: assertEquals(dim, bar.getLayout().preferredLayoutSize(bar));
37: }
38:
39: private void toggleLAF() throws Exception {
40: LookAndFeel laf = UIManager.getLookAndFeel();
41: if (laf == null
42: || laf.getName().equals(
43: UIManager.getSystemLookAndFeelClassName())) {
44: UIManager.setLookAndFeel(UIManager
45: .getCrossPlatformLookAndFeelClassName());
46: } else {
47: UIManager.setLookAndFeel(UIManager
48: .getSystemLookAndFeelClassName());
49: }
50: }
51: }
|