Results 1 to 5 of 5
  1. #1
    applewood13 is offline Member
    Join Date
    Dec 2009
    Posts
    14
    Rep Power
    0

    Post How to wrap text in a JList

    I have a JList but i dont want it to have a horizontal scroll bar, i want the text that doesnt fit to be wrapped onto the next line. Does anyone know the code that will wrap it? I know in a TextArea you can use ".setLineWrap(true);" to make it wrap but its different for JLists

    Any help would be appreciated

  2. #2
    Join Date
    May 2011
    Location
    Munich
    Posts
    15
    Rep Power
    0

    Default

    Just use create a CellRenderer and return a TextArea instead of a Textfield (or whatever it is). Then setLineWrap(true).. should work i think. How does it not work?
    read my blog : www.blue-walrus.com

  3. #3
    applewood13 is offline Member
    Join Date
    Dec 2009
    Posts
    14
    Rep Power
    0

    Default

    Yea, it works for TextArea but im looking to wrap text in a JList, however it is different than a TextArea so the setLineWrap doesnt work for JLists, i was wondering if there was a line of code to wrap writing in a JList or if you have to do something else

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by applewood13 View Post
    Yea, it works for TextArea but im looking to wrap text in a JList, however it is different than a TextArea so the setLineWrap doesnt work for JLists, i was wondering if there was a line of code to wrap writing in a JList or if you have to do something else
    Did you actually read and understand the recommendations that oliver watkins gave you or just gloss over it? He's talking about using a JTextArea as the cell renderer for a JList, and this as far as I know should work.

  5. #5
    applewood13 is offline Member
    Join Date
    Dec 2009
    Posts
    14
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    Did you actually read and understand the recommendations that oliver watkins gave you or just gloss over it? He's talking about using a JTextArea as the cell renderer for a JList, and this as far as I know should work.
    sorry, i must have misunderstood what he was talking about, how exactly would you go about making a cell renderer? because i have not used them yet

Similar Threads

  1. word wrap text in rows of Jtable
    By pink123 in forum AWT / Swing
    Replies: 3
    Last Post: 03-10-2011, 07:20 PM
  2. JList item text does not truncate when it's HTML
    By edsporty in forum New To Java
    Replies: 1
    Last Post: 03-02-2011, 08:09 PM
  3. Populating a JList from a text file - Netbeans
    By Ben1 in forum AWT / Swing
    Replies: 1
    Last Post: 01-13-2011, 03:30 PM
  4. JTextArea Wrap Around or something?
    By Krooger in forum New To Java
    Replies: 6
    Last Post: 11-28-2009, 04:29 AM
  5. How do I display a JList with icons and text?
    By aneesahamedaa in forum AWT / Swing
    Replies: 2
    Last Post: 09-04-2008, 08:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •