⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapcomboboxmodel.java

📁 oraily的Swing hacks code
💻 JAVA
字号:
import java.util.*;import java.awt.event.*;public class MapComboBoxModel extends ListComboBoxModel {    protected Map map_data;    protected List index;    public MapComboBoxModel() {        this.map_data = new HashMap();        index = new ArrayList();    }    public MapComboBoxModel(Map map) {        this.map_data = map;        buildIndex();        if(index.size() > 0) {            selected = index.get(0);        }    }    protected void buildIndex() {        index = new ArrayList(map_data.keySet());    }    public Object getElementAt(int i) {        return index.get(i);    }    public int getSize() {        return map_data.size();    }            public void actionPerformed(ActionEvent evt) {        if(evt.getActionCommand().equals("update")) {            buildIndex();            fireUpdate();        }    }    public Object getValue(Object selectedItem) {        return map_data.get(selectedItem);    }    public Object getValue(int selectedItem) {        return getValue(index.get(selectedItem));    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -