1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.mlc.swing.layout;
31
32 import java.awt.Component;
33 import java.util.ArrayList;
34 import java.util.List;
35 import java.util.Map;
36
37 import javax.swing.JList;
38 import javax.swing.JScrollPane;
39
40 /***
41 * This is the ComponentBuilder used to build JLists.
42 *
43 * @author Kevin Routley
44 */
45 public class JListComponentBuilder implements ComponentBuilder
46 {
47 List<BeanProperty> properties = new ArrayList<BeanProperty>();
48
49 public List<BeanProperty> getProperties()
50 {
51 return properties;
52 }
53
54 public String getDeclaration(String name, Map<String, Object> properties)
55 {
56 return "javax.swing.JList " + name
57 + "Control = new javax.swing.JList();\njavax.swing.JScrollPane " + name
58 + " = new javax.swing.JScrollPane(" + name + "Control);\n";
59 }
60
61 public Component getInstance(Map<String, Object> properties) throws Exception
62 {
63 JList tree = new JList();
64 JScrollPane scrollPane = new JScrollPane(tree);
65 return scrollPane;
66 }
67
68 public boolean isComponentALayoutContainer()
69 {
70 return false;
71 }
72 public String toString()
73 {
74 return "javax.swing.JList";
75 }
76 public ComponentDef getComponentDef(String name, Map<String, Object> beanProperties)
77 {
78 String imp = "import javax.swing.JList;\n" +
79 "import javax.swing.JScrollPane;";
80 String decl = "JList ${name}Control = new JList();\n" +
81 "JScrollPane ${name} = new JScrollPane(${name}Control);";
82 String add = "${container}.add(${name}, \"${name}\");";
83 ComponentDef cd = new ComponentDef(name,imp,decl,add);
84 return cd;
85 }
86
87 }