KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > data > TestBean


1 /*
2  * $Id: TestBean.java,v 1.1 2004/08/05 01:29: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.swing.data;
9
10 import java.awt.Image JavaDoc;
11
12 import java.awt.image.BufferedImage JavaDoc;
13
14 import java.net.MalformedURLException JavaDoc;
15 import java.net.URL JavaDoc;
16
17 import java.util.ArrayList JavaDoc;
18 import java.util.Date JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.Map JavaDoc;
21 import java.util.HashMap JavaDoc;
22
23 /**
24  * A bean for testing.
25  */

26 public class TestBean {
27
28     private String JavaDoc sValue = "A String";
29     
30     // Primitives
31
private int iValue = 17;
32     private float fValue = 0.17f;
33     private boolean bValue = false;
34     
35     // More complex types
36
private Date JavaDoc date = new Date JavaDoc();
37     private Image JavaDoc image;
38     private String JavaDoc[] array = { "Monday", "Tuesday", "Wednesday", "Thursday",
39                    "Friday", "Saturday", "Sunday" };
40
41     private List JavaDoc list;
42     private Map JavaDoc map;
43
44     // JDNC data types
45
private Link link;
46     
47     public TestBean() {
48
49     // Populate the more complex types.
50
list = new ArrayList JavaDoc();
51     map = new HashMap JavaDoc();
52     for (int i = 0; i < array.length; i++) {
53         list.add(array[i]);
54         map.put(new Integer JavaDoc(i), array[i]);
55     }
56
57     URL JavaDoc testURL;
58     try {
59         testURL = new URL JavaDoc("http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4488581");
60     } catch (MalformedURLException JavaDoc ex) {
61         throw new RuntimeException JavaDoc(ex);
62     }
63
64     link = new Link("4488581", "_blank", testURL);
65     }
66     
67     public void setString(String JavaDoc s) { sValue = s; }
68     public String JavaDoc getString() { return sValue; }
69     
70     public void setInteger(int i) { iValue = i; }
71     public int getInteger() { return iValue; }
72     
73     public void setFloat(float f) { fValue = f; }
74     public float getFloat() { return fValue; }
75
76     public void setBoolean(boolean b) { bValue = b; }
77     public boolean getBoolean() { return bValue; }
78     
79     public void setDate(Date JavaDoc d) { date = d; }
80     public Date JavaDoc getDate() { return date; }
81     
82     public void setImage(Image JavaDoc i) { image = i; }
83     public Image JavaDoc getImage() { return image; }
84
85     public String JavaDoc[] getArray() { return array; }
86     public void setArray(String JavaDoc[] array) { this.array = array; }
87
88     public List JavaDoc getList() { return list; }
89     public void setList(List JavaDoc list) { this.list = list; }
90
91     public Map JavaDoc getMap() { return map; }
92     public void setMap(Map JavaDoc map) { this.map = map; }
93
94     public Link getLink() { return link; }
95     public void setLink(Link link) { this.link = link; }
96 }
97
Popular Tags