java - Changing color when double clicked in the getListCellRendererComponent -
how can change color when double click cell of jlist
? there way adding mouselistener
within defaultlistcellrenderer
?
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; } }
i has similar situation wanted double click table entries , have them added in list. trick to:
- add boolean in table denote 'has been added list'.
- on double click (add row list &) set value true.
- when rendering, check boolean , decide how render it.
Comments
Post a Comment