2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.model.gender;
19 import javax.swing.ComboBoxModel;
20 import org.mxchange.addressbook.client.Client;
21 import org.mxchange.addressbook.model.BaseModel;
25 * @author Roland Haeder
27 public class GenderComboBoxModel extends BaseModel implements ComboBoxModel<String> {
30 * Selected item instance, the value can only be 'M', 'F' or 'C'
32 private char selectedItem = 0;
37 private final char[] validItems = new char[] {'M', 'F', 'C'};
40 * Creates an instance of this model with a Client instance
41 * @param client Client instance
43 public GenderComboBoxModel (final Client client) {
44 // Call super constructor
48 this.setClient(client);
52 public String getElementAt (final int index) {
54 return String.valueOf(this.validItems[index]);
58 * Gets the currently selected item or null if nothing is selected.
60 * @return Selected item or null
63 public Object getSelectedItem () {
64 // Is the char set other than 0?
65 if (this.selectedItem == 0) {
70 // Return string representing the selected item
71 return this.selectedItem;
75 public void setSelectedItem (final Object anItem) {
76 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
80 * Getter for size. Here only 3 values are valid: M, F and C
82 * @return Maximum size
85 public int getSize () {
87 return this.validItems.length;