01: /*
02: * Copyright (c) 2007, Sun Microsystems, Inc.
03: *
04: * All rights reserved.
05: *
06: * Redistribution and use in source and binary forms, with or without
07: * modification, are permitted provided that the following conditions
08: * are met:
09: *
10: * * Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * * Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in
14: * the documentation and/or other materials provided with the
15: * distribution.
16: * * Neither the name of Sun Microsystems, Inc. nor the names of its
17: * contributors may be used to endorse or promote products derived
18: * from this software without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
24: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31: */
32:
33: /*
34: * CurrenciesSelector.java
35: */
36: package converter;
37:
38: import javax.microedition.lcdui.*;
39:
40: /**
41: *
42: */
43: public class CurrenciesSelector extends List implements CommandListener {
44:
45: private ConverterMIDlet midlet;
46:
47: /**
48: * constructor
49: */
50: public CurrenciesSelector(ConverterMIDlet midlet) {
51: super ("Select Currencies", List.MULTIPLE, midlet.currencies,
52: null);
53: this .midlet = midlet;
54: setSelectedFlags(midlet.selected);
55: try {
56: // Set up this list to listen to command events
57: setCommandListener(this );
58: // Add the Save command
59: addCommand(new Command("Save", Command.OK, 1));
60: } catch (Exception e) {
61: e.printStackTrace();
62: }
63: }
64:
65: /**
66: * Called when action should be handled
67: */
68: public void commandAction(Command command, Displayable displayable) {
69: if (command.getCommandType() == Command.OK) {
70: getSelectedFlags(midlet.selected);
71: midlet.notifySettingsChanged();
72: }
73: }
74:
75: }
|