From 453a815ba0a3bdae7ec565b9a77549fb112b0c3d Mon Sep 17 00:00:00 2001 From: hche10x Date: Mon, 23 Oct 2006 02:51:55 +0000 Subject: 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 --- .../common/ui/iCheckBoxList/ICheckBoxList.java | 25 ++++++++++++++++++++++ .../common/ui/iCheckBoxList/ICheckBoxListItem.java | 10 +++++++++ 2 files changed, 35 insertions(+) diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxList.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxList.java index 2361c77e61..6fbdf03ddd 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxList.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxList.java @@ -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(); } diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListItem.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListItem.java index 39fa641d0e..a087887e2f 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListItem.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListItem.java @@ -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; + } + } -- cgit v1.2.3