📄 jmlistcellrenderer.java
字号:
package jm.framework.gui.module.render ;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import jm.framework.gui.module.JMItemCode;
public class JMListCellRenderer
implements ListCellRenderer
{
Color backColor = null;
public JMListCellRenderer (Color selBackColor)
{
super();
backColor = selBackColor ;
}
/**
* Return a component that has been configured to display the specified
* value.
*
* @param list The JList we're painting.
* @param value The value returned by
* list.getModel().getElementAt(index).
* @param index The cells index.
* @param isSelected True if the specified cell was selected.
* @param cellHasFocus True if the specified cell has the focus.
* @return A component whose paint() method will render the specified
* value.
* @todo Implement this javax.swing.ListCellRenderer method
*/
public Component getListCellRendererComponent (
JList list ,
Object value ,
int index ,
boolean isSelected ,
boolean cellHasFocus
)
{
JLabel oListLabel = new JLabel ( ""+value ) ;
oListLabel.setOpaque ( true ) ;
if(isSelected)
{
oListLabel.setFont ( JMItemCode.FT_TABLE_SELECT ) ;
}
else
{
oListLabel.setFont ( JMItemCode.FT_CELLS ) ;
}
if(backColor!=null)
{
oListLabel.setBackground ( isSelected ? backColor : Color.white ) ;
oListLabel.setForeground ( isSelected ? Color.white : Color.black ) ;
}
return oListLabel ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -