[英]Java - Get all data from another class stored in a static List
This is the Dialog class where I add new person to a static List 这是Dialog类,我在其中添加新人员到静态列表
public class DialogInput extends Dialog{
public static List<Person> person = new LinkedList<Person>();
Text txtName;
@Override
protected Control createPartControl(Composite parent){
...
txtName = new Text(parent, SWT.NONE);
}
@Override
protected void okPressed(){
Person p = new Person();
p.setName(txtName.getText());
person.add(p);
}
}
// ANOTHER CLASS in a different file. //其他文件中的另一个类。
public class MyView extends ViewPart{
public void createPartControl(Composite parent){
// HOW TO GET LIST ?
}
}
public class MyView extends ViewPart{
public void createPartControl(Composite parent){
// HOW TO GET LIST ?
List<Person> personList = DialogInput.person;
}
}
Try this: 尝试这个:
public class MyView extends ViewPart{
public void createPartControl(Composite parent){
List<String> pList = DialogInput.person;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.