我正在开发我的第一个GUI应用程序.
我有一个ArrayList父类Plant,我有四个子类.
我有一些JTextField信息和一些JCheckBox其他信息......
的JTextFieldS的关系被转换成StringS和JCheckBoxs转换boolean.
我需要将所有这些组件添加到a ArrayList,然后显示Plants 的列表.
我怎样才能做到这一点?
例:
public class Flower extends Plant{
private boolean thorns;
private boolean smell;
public Flower(String name, String id, String color, boolean blnThorns, boolean blnSmell){
super(name, id, color);
thorns = blnThorns;
smell = blnSmell;
}
public boolean isThorns(){
return thorns;
}
public void setThorns(boolean blnThorns){
thorns = blnThorns;
}
public boolean isSmell(){
return smell;
} …Run Code Online (Sandbox Code Playgroud)