Chat Client emoticons window JAVA

前端 未结 3 737
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 08:33

I\'ve been working on creating a chat client(java swing) and I\'ve just made my emoticons fully useable but other than having users type \":)\" for example, I want to provid

3条回答
  •  死守一世寂寞
    2020-11-27 09:13

    This ListPanel might be a useful, as the DefaultListCellRenderer can display an Icon.

    enter image description here

    Icon icon = UIManager.getIcon("html.pendingImage");
    ...
    @Override
    public Component getListCellRendererComponent(JList list, Object
        value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel label =  (JLabel) super.getListCellRendererComponent(
            list, value, index, isSelected, cellHasFocus);
        label.setBorder(BorderFactory.createEmptyBorder(N, N, N, N));
        label.setIcon(icon);
        label.setHorizontalTextPosition(JLabel.CENTER);
        label.setVerticalTextPosition(JLabel.BOTTOM);
        return label;
    }
    

提交回复
热议问题