📄 icon.java
字号:
package com.softfz.jn0708.main.user;
/*
* 实现渲染器,加载下拉框图片
*/
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
/**
* 实现渲染器,加载下拉框图片
* @author admin
*
*/
public class Icon extends JLabel implements ListCellRenderer {
private static final long serialVersionUID = 1L;
private String fileName ;
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value!=null){
// File file=new File("./src/com/softfz/jn0708/images/face/");
// File[] fileList=file.listFiles();
// for (int i=0;i<fileList.length;i++){
// URL url = Images.class.getResource("face/"+fileList[i].getName());
// ImageIcon icon = new ImageIcon(url);
// }
fileName=value.toString();
setIcon(new ImageIcon("./images/head/"+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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -