01: /*
02: * Created on 10/02/2005
03: *
04: * ============================================================================
05: * GNU Lesser General Public License
06: * ============================================================================
07: *
08: * Swing Components - visit http://sf.net/projects/gfd
09: *
10: * Copyright (C) 2004 Igor Regis da Silva Simões
11: *
12: * This library is free software; you can redistribute it and/or
13: * modify it under the terms of the GNU Lesser General Public
14: * License as published by the Free Software Foundation; either
15: * version 2.1 of the License, or (at your option) any later version.
16: *
17: * This library is distributed in the hope that it will be useful,
18: * but WITHOUT ANY WARRANTY; without even the implied warranty of
19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20: * Lesser General Public License for more details.
21: *
22: * You should have received a copy of the GNU Lesser General Public
23: * License along with this library; if not, write to the Free Software
24: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
25: */
26: package br.com.igor.beans;
27:
28: import java.util.Arrays;
29: import java.util.HashMap;
30: import java.util.Iterator;
31: import java.util.Locale;
32: import java.util.Map;
33: import java.util.Set;
34:
35: import javax.swing.ComboBoxModel;
36: import javax.swing.DefaultComboBoxModel;
37: import javax.swing.JComboBox;
38:
39: /**
40: *
41: * @author Igor Regis da Silva Simoes - f4353008
42: * @since 10/02/2005 16:59:20
43: */
44: public class CountryEditor extends JComboBox {
45: /**
46: *
47: */
48: public CountryEditor() {
49: Locale[] locais = Locale.getAvailableLocales();
50: Map<String, String> paises = new HashMap<String, String>(30);
51:
52: for (int i = 0; i < locais.length; i++) {
53: paises.put(locais[i].getCountry(), "");
54: }
55:
56: Set temp = paises.keySet();
57: Iterator listaDePaises = temp.iterator();
58: String[] paisesArray = new String[temp.size()];
59:
60: for (int i = 0; i < paisesArray.length; i++) {
61: paisesArray[i] = listaDePaises.next().toString();
62: }
63:
64: Arrays.sort(paisesArray);
65: ComboBoxModel model = new DefaultComboBoxModel(paisesArray);
66: setModel(model);
67: setRenderer(new LocaleComboBoxRenderer());
68: }
69: }
|