1 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 ; 16 import java.awt.event.ActionEvent ; 17 18 import javax.swing.JComponent ; 19 import javax.swing.JFrame ; 20 import javax.swing.JLabel ; 21 import javax.swing.UIManager ; 22 23 import junit.framework.TestCase; 24 25 26 27 public class JNFormUnitTest extends TestCase { 28 29 public static final String creditCardTypes[] = { 30 "VISA", "MasterCard", "American Express" 31 }; 32 33 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 .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 e) { 61 System.out.println(e); 62 } 63 64 JFrame frame = new JFrame ("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 args[]) { 72 JNFormUnitTest test = new JNFormUnitTest(); 73 test.interactiveTestJNForm1(); 74 } 75 } 76 | Popular Tags |