扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共4页)
?
/*
?* @author 陈刚 ,2004-8-21 15:33:17
?* Email: glchengang@yeah.net
?* Blog : glchengang.yeah.net
?*/
package book.c3.e2;
import java.util.List;
/**
?* 城市的实体类
?*/
public class City implements TreeEntry{
??? private String name;//城市名
??? private List peoples;
??? public City() {}
??? public City(String name) {
??????? this.name = name;
??? }
??? public String getName() {
??????? return name;
??? }
??? public void setName(String name) {
??????? this.name = name;
??? }
??? public List getPeoples() {
??????? return peoples;
??? }
??? public void setPeoples(List peoples) {
??????? this.peoples = peoples;
??? }
}
?
/*
?* @author 陈刚 ,2004-8-21 18:15:53
?* Email: glchengang@yeah.net
?* Blog : glchengang.yeah.net
?*/
package book.c3.e2;
/**
?* 人的实体类
?*/
public class People implements TreeEntry{
??? private String name;
??? public People() {}
??? public People(String name) {
??????? this.name = name;
??? }
??? public String getName() {
??????? return name;
??? }
??? public void setName(String name) {
??????? this.name = name;
??? }
}
?
/*
?* @author 陈刚 ,2004-8-21 17:52:27
?* Email: glchengang@yeah.net
?* Blog : glchengang.yeah.net
?*/
package book.c3.e2;
import java.util.ArrayList;
import java.util.List;
/**
?* 此类负责生成TreeViewer的方法setInput所需要的参数
?*/
public class TvInputFactory {
??? public Object build() {
??????? /*
???????? * 生成顶级的三个对象
???????? */
??????? Country[] countryArray = new Country[3];
??????? countryArray[0] = new Country("中国");
??????? countryArray[1] = new Country("美国");
??????? countryArray[2] = new Country("英国");
??????? /*
???????? * 生成中国的三个城市
???????? */
??????? List chinaList = new ArrayList();
??????? chinaList.add(new City("北京"));
??????? City glCity = new City("桂林");
??????? chinaList.add(glCity);
??????? City nnCity = new City("南宁");
??????? chinaList.add(nnCity);
??????? countryArray[0].setCities(chinaList);
??????? /*
???????? * 生成美国的两个城市
???????? */
??????? List usaList = new ArrayList();
??????? usaList.add(new City("纽约"));
??????? usaList.add(new City("芝加哥"));
??????? countryArray[1].setCities(usaList);
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者