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

📄 owncellrenderer.java

📁 这是一个简单的图书管理系统,适用于教学中演示,讲解java高级编程语言
💻 JAVA
字号:
package helpfile;import javax.swing.ListCellRenderer;import java.awt.Component;import javax.swing.JList;import javax.swing.*;import java.awt.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class OwnCellRenderer extends JLabel implements ListCellRenderer {  private Icon[] icons;  public OwnCellRenderer(Icon[] icons) {    this.icons = icons;    this.setOpaque(true);    this.setFont(new Font("Dialog",Font.PLAIN,16));  }  public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {    /**@todo Implement this javax.swing.ListCellRenderer method*/    if(value!=null){        String text = value.toString();        this.setText(text);    }    this.setIcon(icons[index]);    if(isSelected){        this.setBackground(list.getSelectionBackground());        this.setForeground(list.getSelectionForeground());    }    else{        this.setBackground(list.getBackground());        this.setForeground(list.getForeground());    }    return this;    //throw new java.lang.UnsupportedOperationException("Method getListCellRendererComponent() not yet implemented.");  }}

⌨️ 快捷键说明

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