Jlist Jlabel位置

时间:2015-03-22 21:42:43

标签: jlabel jlist

大家好(对不起我的英文) 我对Jlist Cell renderer有疑问,因为getlistcellrenderer中返回的组件我选择返回包含Jpanel的{​​{1}},但问题是我无法获得当我问Jlabel时屏幕上的位置,我确实需要这个,以便能够点击"在上面。有帮助吗?

1 个答案:

答案 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
}