KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdnc > JNFormUnitTest


1 /*
2  * $Id: JNFormUnitTest.java,v 1.1 2004/07/31 00:17:19 davidson1 Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.jdnc;
9
10 import org.jdesktop.swing.data.DefaultDataModel;
11 import org.jdesktop.swing.data.MetaData;
12 import org.jdesktop.swing.data.EnumeratedMetaData;
13 import org.jdesktop.swing.data.StringMetaData;
14
15 import java.awt.BorderLayout JavaDoc;
16 import java.awt.event.ActionEvent JavaDoc;
17
18 import javax.swing.JComponent JavaDoc;
19 import javax.swing.JFrame JavaDoc;
20 import javax.swing.JLabel JavaDoc;
21 import javax.swing.UIManager JavaDoc;
22
23 import junit.framework.TestCase;
24
25
26
27 public class JNFormUnitTest extends TestCase {
28
29     public static final String JavaDoc creditCardTypes[] = {
30         "VISA", "MasterCard", "American Express"
31     };
32
33     // Dummy test. Remove when real tests have been added.
34
public void testDummy() {
35     }
36
37     public void interactiveTestJNForm1() {
38         DefaultDataModel billingModel = new DefaultDataModel();
39
40         StringMetaData metaData = new StringMetaData("name", "Name on Credit Card");
41         billingModel.addField(metaData);
42
43         EnumeratedMetaData enumMetaData = new EnumeratedMetaData("type", String JavaDoc.class, "Type");
44         enumMetaData.setEnumeration(creditCardTypes);
45         enumMetaData.setMinValueCount(1);
46         billingModel.addField(enumMetaData);
47
48         metaData = new StringMetaData("number", "Number");
49         metaData.setMaxLength(16);
50         metaData.setMinValueCount(1);
51         billingModel.addField(metaData);
52
53         metaData = new StringMetaData("expiration", "Expiration");
54         metaData.setMinValueCount(1);
55         billingModel.addField(metaData);
56
57         JNForm form = new JNForm();
58         try {
59             form.bind(billingModel);
60         } catch (Exception JavaDoc e) {
61             System.out.println(e);
62         }
63
64         JFrame JavaDoc frame = new JFrame JavaDoc("Form Test1");
65         frame.getContentPane().add(BorderLayout.CENTER, form);
66         frame.pack();
67         frame.setVisible(true);
68
69     }
70
71     public static void main(String JavaDoc args[]) {
72         JNFormUnitTest test = new JNFormUnitTest();
73         test.interactiveTestJNForm1();
74     }
75 }
76
Popular Tags