当前位置: 代码迷 >> J2SE >> JComboBox下拉框如何显示图片选项
  详细解决方案

JComboBox下拉框如何显示图片选项

热度:96   发布时间:2016-04-23 21:43:38.0
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