日期:2014-05-20  浏览次数:20642 次

JComboBox下拉框怎么显示图片选项?
[code=java][/codeprivate class ComboBoxRenderer extends JLabel implements ListCellRenderer {

        @Override
        public Component getListCellRendererComponent(JList list, Object value,
                int index, boolean isSelected, boolean cellHasFocus) {
 
             // check if this cell represents the current DnD drop location
             JList.DropLocation dropLocation = myList.getDropLocation();
             if (dropLocation != null
                     && !dropLocation.isInsert()
                     && dropLocation.getIndex() == index) {
            
             // check if this cell is selected
             } else if (isSelected) {
                 
             } else {
                  
             };
 
             return this;
         }

我想做个下拉选择框,里面的选项是图片的形式该怎么写?写个Icon[] 对象数组存图片,怎么样才会显示在下拉框里面?上面的代码要怎么写?
java

------解决方案--------------------
http://www.java2s.com/Tutorial/Java/0240__Swing/Comboboxcellrenderer.htm