0
當雙擊單元格JList
時,如何更改顏色? 有沒有辦法在DefaultListCellRenderer
內添加MouseListener
?在getListCellRendererComponent中雙擊時更改顏色
public class Renderer extends DefaultListCellRenderer{
@Override
public Component getListCellRendererComponent(JList list, Object value, int index,boolean isSelected, boolean cellHasFocus)
{
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if(isSelected){
c.setBackground(Color.ORANGE);
c.setForeground(Color.BLACK);
}
return c;
}
}