1. Update ICheckBoxList to add one attribute "selected". Set the first item of ICheckBoxList selected when it is inited.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1820 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
hche10x 2006-10-23 02:51:55 +00:00
parent bf1168562b
commit 453a815ba0
2 changed files with 35 additions and 0 deletions

View File

@ -50,6 +50,14 @@ public class ICheckBoxList extends JList {
model.addElement(items.elementAt(index));
}
}
//
// If there exists at least one item, set first item selected.
//
if (model.size() > 0) {
ICheckBoxListItem listItem = (ICheckBoxListItem) model.get(0);
listItem.setSelected(true);
}
this.setCellRenderer(cellrenderer);
this.setModel(model);
this.addMouseListener(listener);
@ -69,6 +77,14 @@ public class ICheckBoxList extends JList {
model.addElement(new ICheckBoxListItem(items.elementAt(index)));
}
}
//
// If there exists at least one item, set first item selected.
//
if (model.size() > 0) {
ICheckBoxListItem listItem = (ICheckBoxListItem) model.get(0);
listItem.setSelected(true);
}
}
/**
@ -149,6 +165,15 @@ public class ICheckBoxList extends JList {
}
}
}
//
// If there exists at least one item, set first item selected.
//
if (model.size() > 0) {
ICheckBoxListItem listItem = (ICheckBoxListItem) model.get(0);
listItem.setSelected(true);
}
this.validate();
}

View File

@ -22,6 +22,8 @@ public class ICheckBoxListItem {
protected String text;
protected boolean checked;
protected boolean selected;
/**
This is the default constructor to set check box item string
@ -71,4 +73,12 @@ public class ICheckBoxListItem {
this.text = text;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}