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 provide a popup window with all the available emoticons. What I'm searching for is a way to make such a window( for example like Skype's). How and with what can I go about it? I've tried with a JMenu, but it doesn't do what I want. I want to put a small image(probably emoticon) near the enter text area and when it's clicked, a square filled with emoticons pops up and on mouse click for example ":)" is entered in the text area.
            Asked
            
        
        
            Active
            
        
            Viewed 3,569 times
        
    0
            
            
        - 
                    Your question needs to be a little more specific. What exactly do you mean by 'popup window' as opposed to a normal JFrame? What have you tried so far and what problems did you encounter? – devrobf Dec 06 '12 at 20:49
 - 
                    @Martin what logic did you used for placing emoticons in your chat window?? I am having some problem with Implementation any help will be appreciated, thanks – Muhammad Sep 29 '14 at 14:50
 
3 Answers
3
            
            
        This ListPanel might be a useful, as the DefaultListCellRenderer can display an Icon.

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;
}
1
            
            
        In the absence of more information, I assume that what you are really after is a window which appears without window decorations (i.e. borders and title bar) and which does not show in the task bar. I therefore suggest you look at the JWindow documentation, which does exactly this.
        devrobf
        
- 6,973
 - 2
 - 32
 - 46
 
1
            I suppose you mean a chat window like this sort. In that case, you'll need to learn how to layer components over one another, in this case a jPanel, or a jLayeredPane nested inside the main jFrame.

        turnt
        
- 3,235
 - 5
 - 23
 - 39