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:
@ -50,6 +50,14 @@ public class ICheckBoxList extends JList {
|
|||||||
model.addElement(items.elementAt(index));
|
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.setCellRenderer(cellrenderer);
|
||||||
this.setModel(model);
|
this.setModel(model);
|
||||||
this.addMouseListener(listener);
|
this.addMouseListener(listener);
|
||||||
@ -69,6 +77,14 @@ public class ICheckBoxList extends JList {
|
|||||||
model.addElement(new ICheckBoxListItem(items.elementAt(index)));
|
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();
|
this.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@ public class ICheckBoxListItem {
|
|||||||
protected String text;
|
protected String text;
|
||||||
|
|
||||||
protected boolean checked;
|
protected boolean checked;
|
||||||
|
|
||||||
|
protected boolean selected;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is the default constructor to set check box item string
|
This is the default constructor to set check box item string
|
||||||
@ -71,4 +73,12 @@ public class ICheckBoxListItem {
|
|||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSelected() {
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(boolean selected) {
|
||||||
|
this.selected = selected;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user