JCombobox使用hasmap / no point模型

时间:2015-03-27 20:07:41

标签: java jcombobox

嘿,我正在寻找解决我需要为jcombobox制作模型的问题。 我有一个:

 Map<Integer, Pathes_format> profiles =new HashMap<Integer, Pathes_format>();

我想在jcombobox上显示pathes_format.getname将显示在索引pathes_format.GetiD我从未写过或触摸抽象类或模型。

我在这里做了什么

package subDialogs;

import java.util.HashMap;
import java.util.Map;

import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;

import json.Pathes_format;

public class PatheseModel implements ComboBoxModel {

Map<Integer, Pathes_format> profiles =new HashMap<Integer, Pathes_format>();
int index=-1;
@Override
public int getSize() {
    // TODO Auto-generated method stub
    return profiles.size();
}

@Override
public Object getElementAt(int index) {
    // TODO Auto-generated method stub
    return profiles.get(index);
}

@Override
public void addListDataListener(ListDataListener l) {
    // TODO Auto-generated method stub

}

@Override
public void removeListDataListener(ListDataListener l) {
    // TODO Auto-generated method stub

}

@Override
public void setSelectedItem(Object anItem) {
    // TODO Auto-generated method stub

}

@Override
public Object getSelectedItem() {
    // TODO Auto-generated method stub
    return null;
}
//void addElement(Object obj){
//  
//}
void insertElementAt(Object obj, int index) {
    profiles.put(index, (Pathes_format) obj);

}
void removeElement(Object obj) {
    Pathes_format tmp = profiles.get(obj);
    tmp=null;

}
void removeElementAt(int index){
    profiles.remove(index);

}

}

我不知道这是对的:/。我应该制作一个单独的格式补丁而不是地图;并添加添加地图的能力??

0 个答案:

没有答案