1 7 8 package org.jdesktop.swing; 9 10 import java.awt.Color ; 11 import java.awt.Dimension ; 12 import java.awt.Point ; 13 import javax.swing.Icon ; 14 import javax.swing.ImageIcon ; 15 import javax.swing.JComponent ; 16 import javax.swing.JFrame ; 17 import javax.swing.JPanel ; 18 19 import org.jdesktop.swing.MatteBorderExt; 20 21 public class MatteBorderExtUnitTest extends junit.framework.TestCase { 22 public MatteBorderExtUnitTest() { 23 super("MatteBorderExt unit test"); 24 } 25 26 public void testDummy() { } 28 29 public static void main(String [] args) { 30 try { 31 } 33 catch (Exception ex) { 34 35 } 36 37 final TestCase[] testCases = createTestCases(); 38 if (testCases.length > 0) { 39 testCases[testCases.length - 1].frame.setDefaultCloseOperation( 41 JFrame.EXIT_ON_CLOSE); 42 43 Point location = testCases[0].frame.getLocation(); 44 45 for (int i = testCases.length - 1; i >= 0; i--) { 46 location.translate(30, 30); testCases[i].frame.setTitle("MatteBorderExt Unit Test " + (i + 48 1)); 49 testCases[i].frame.setLocation(location); 50 testCases[i].frame.setVisible(true); 51 } 52 } 53 } 54 55 59 private static TestCase[] createTestCases() { 60 final TestCase[] testCases = new TestCase[] { 61 62 new TestCase() { public JComponent define() { 64 Class klass = MatteBorderExtUnitTest.class; 65 Icon [] icons = new Icon [] { 66 new ImageIcon (klass.getResource("resources/images/wellTopLeft.gif")), 67 new ImageIcon (klass.getResource("resources/images/wellTop.gif")), 68 new ImageIcon (klass.getResource("resources/images/wellTopRight.gif")), 69 new ImageIcon (klass.getResource("resources/images/wellRight.gif")), 70 new ImageIcon (klass.getResource("resources/images/wellBottomRight.gif")), 71 new ImageIcon (klass.getResource("resources/images/wellBottom.gif")), 72 new ImageIcon (klass.getResource("resources/images/wellBottomLeft.gif")), 73 new ImageIcon (klass.getResource("resources/images/wellLeft.gif")), 74 }; 75 76 JPanel panel = new JPanel (); 77 panel.setBackground(Color.white); 78 panel.setBorder(new MatteBorderExt(14, 14, 14, 14, icons)); 79 return panel; 80 } 81 }, 82 83 }; 84 return testCases; 85 } 86 87 private static abstract class TestCase { 88 89 public TestCase() { 90 this.frame = wrap(define()); 91 } 92 93 public abstract JComponent define(); 94 95 public JFrame wrap(JComponent component) { 96 this.component = component; 97 final JFrame frame = new JFrame (); 98 frame.getContentPane().add(component); 99 frame.pack(); 100 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 101 return frame; 102 } 103 104 public JComponent component; 105 public final JFrame frame; 106 107 } 108 } 109 | Popular Tags |