3 The file is used to create listener for Checkbox List
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 package org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
;
17 import java
.awt
.event
.*;
19 class ICheckBoxListener
implements MouseListener
, KeyListener
{
21 protected ICheckBoxList iCheckboxlist
;
24 This is the default constructor
29 public ICheckBoxListener(ICheckBoxList parent
) {
30 iCheckboxlist
= parent
;
34 * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
35 * Override to deal with keyReleased event
39 public void keyReleased(KeyEvent e
) {
40 Object
[] selectedValues
= iCheckboxlist
.getSelectedValues();
41 int[] selectedIndices
= iCheckboxlist
.getSelectedIndices();
43 for (int index
= 0; index
< selectedValues
.length
; index
++) {
44 ICheckBoxListItem item
= (ICheckBoxListItem
) selectedValues
[index
];
46 if (iCheckboxlist
.isEnabled()) {
47 if (e
.getKeyCode() == KeyEvent
.VK_SPACE
) {
49 //if press space key, then reverse all selected item.
53 ((ICheckBoxListModel
) iCheckboxlist
.getModel()).setElementAt(item
, selectedIndices
[index
]);
60 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
61 * Override to deal with mouse clicked event
64 public void mouseClicked(MouseEvent e
) {
65 int index
= iCheckboxlist
.locationToIndex(e
.getPoint());
66 ICheckBoxListItem item
= null;
67 item
= (ICheckBoxListItem
) iCheckboxlist
.getModel().getElementAt(index
);
69 if (item
!= null && iCheckboxlist
.isEnabled()) {
71 ((ICheckBoxListModel
) iCheckboxlist
.getModel()).setElementAt(item
, index
);
75 public void mousePressed(MouseEvent arg0
) {
76 // TODO Auto-generated method stub
80 public void mouseReleased(MouseEvent arg0
) {
81 // TODO Auto-generated method stub
85 public void mouseEntered(MouseEvent arg0
) {
86 // TODO Auto-generated method stub
90 public void mouseExited(MouseEvent arg0
) {
91 // TODO Auto-generated method stub
95 public void keyPressed(KeyEvent arg0
) {
96 // TODO Auto-generated method stub
100 public void keyTyped(KeyEvent arg0
) {
101 // TODO Auto-generated method stub