iconcombobox.java
来自「用java开发的QQ管理系统」· Java 代码 · 共 47 行
JAVA
47 行
package com.zlf.qqserver.usermngpanel;
import java.awt.Component;
import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import com.zlf.qqserver.utils.QQUtils;
/**
* 图片下拉框
*
* @author zlf
*
*/
public class IconCombobox extends JLabel implements ListCellRenderer {
/**
*
*/
private static final long serialVersionUID = 8984799696707884305L;
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
if (value != null) {
String fileName =((File)value).getName();
this.setIcon(new ImageIcon(QQUtils.properties.getProperty("NewFace")+fileName));
}
if(isSelected){
this.setBackground(list.getSelectionBackground());
this.setForeground(list.getSelectionForeground());
}else{
this.setBackground(list.getBackground());
this.setForeground(list.getForeground());
}
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 3));
this.setOpaque(true);
return this;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?