Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use new line character within a ToolTip [duplicate]

Possible Duplicate:
Multi-line tooltips in Java?

It is very strange. All I wish to do is make my tool tip multi-lined. I have added the "\n" character to the string I am passing at appropriate places. In fact, I print out that same string, and it does have the line breaks. However, the tooltip does not. Here is what I do:

        @Override
        public void itemStateChanged(ItemEvent arg0) {
            if(arg0.getStateChange() == ItemEvent.SELECTED){
                String s = arg0.getItem().toString();
                for(InfoContainer i: mc.myInfo)
                    if(s.equals(i.getId())){
                        selector.setToolTipText(i.getInfo());
                        System.out.println(i.getInfo());
                        return;
                    }
            }
        }

However, the tooltip does NOT have the carriage returns, while the System printout DOES.

like image 821
MirroredFate Avatar asked Jul 13 '11 21:07

MirroredFate


1 Answers

How about using: "<html>" + firstLine + "<br>" + secondLine + "</html>"

like image 189
Eng.Fouad Avatar answered Sep 23 '22 06:09

Eng.Fouad