Skip to content Skip to sidebar Skip to footer

Add A Jscrollpane To A Jlabel

I can't seem to find out how I can add a JScrollPane to a JLabel. The JLabel that I'm using is populated with a long formatted HTML string. Please help. area = new JLabel(); JScro

Solution 1:

Really not good idea to hold or display long Html formatted text in the JLabel, since is possible, better would be use JEditorPanes / JTextPanes, these JComponets support styled and html formatted text, Icons etc ... , examples for JTextPane and JEditorPane

Solution 2:

Can you provide us your code? Are you setting the viewport view to the JLabel? Instantiate your JLabel and a JScrollPane. then set the JScrollPane viewport to the JLabel (setViewPortView(jlabel);) then add the JScrollPane to whatever component you want the scrolling JLabel to be on.

Hope this helps!

Solution 3:

You can't add a JScrollPane to a JLabel , what you can do is to create a JScrollPane and add a JLabel.

See this: http://www.cs.cf.ac.uk/Dave/HCI/HCI_Handout_CALLER/node63.html

Solution 4:

You need to set the JScrollPane's viewport view:

scroller.setViewPortView(area);

stick that line just before you go panel.add(scroller);

Let us know if that helps or not.

Post a Comment for "Add A Jscrollpane To A Jlabel"