大家好(对不起我的英文)
我对Jlist Cell renderer
有疑问,因为getlistcellrenderer
中返回的组件我选择返回包含Jpanel
的{{1}},但问题是我无法获得当我问Jlabel
时屏幕上的位置,我确实需要这个,以便能够点击"在上面。有帮助吗?
答案 0 :(得分:0)
public Component getListCellRendererComponent(JList list,Object value,int index,boolean isSelected,boolean cellHasFocus){ 电影f =(电影)值;
list.setBackground(new Color(242,242,242));
ImageIcon ii = new ImageIcon(f.getPoster());
poster.setIcon(ii); //JLabel
infos.setText(//JLabel
"Title: "+f.getTitle()+
"\nSynopsis: "+f.getSynopsis()+
"\nActors: "+f.getActorsNames()+
"\nGenres: "+f.getGenresNames()
);
l = list;
isOn = isSelected;
if(isSelected) {
bin.setVisible(isSelected);//JLabel
modify.setVisible(isSelected);//Jlabel
}else{
modify.setVisible(false);
bin.setVisible(false);
update();
}
return this;//Jpanel
}