Dynamically word wrap in a JLabel

I have several JLabels in a complex layout that has a JSplitter and is in a resizeable window.
I would like it if there isn't enough room for the text of the JLabel to fit on one line, but there is enough vertical room (there almost always is), for the JLabel to automatically word wrap, and become 2 or three line, as needed. (There are usually only 2 or three words in these JLabels.
I haven't found a way to do this. I know about putting HTML in the JLabel lets you put <BR>s in, but I would like the JLabel to be only one line if possible, going to two line if there isn't enough room to fit all the text on one line.
I searched this forum, and found a suggestion to use a JTextArea made up to look like a JLabel ( http://forum.java.sun.com/thread.jsp?forum=57&thread=399180 second reply from bottom ), but this has it's own problems. The JTextAreas, try to take up as much vertical space as possible instead of only as much space a necessary (as a JLable does) in the layout that I'm using.
Is there any way of doing this?

JLabel label = new JLabel();
label.setLayout new BorderLayout() ;
JTextPane pane = new JTextPane();
pane.setBackground(label.getBackground());
// or try making it opaque
pane.setText("long text here");
label.add(pane,BorderLayout.CENTER);The above still has the problem of wanting its preferred size to be calculated from the text layed out in one line. I was digged around in my Java2D folder and found some old code I wrote, based on something by J. Knudsen:
import java.awt.*;
import java.awt.font.*;
import java.text.*;
import javax.swing.*;
public class JMultilineLabel extends JComponent {
    private String text;
    private Insets margin = new Insets(5,5,5,5);
    private int maxWidth = Integer.MAX_VALUE;
    private boolean justify;
    private final FontRenderContext frc = new FontRenderContext(null, false, false);
    private void morph() {
        revalidate();
        repaint();
    public String getText() {
        return text;
    public void setText(String text) {
        String old = this.text;
        this.text = text;
        firePropertyChange("text", old, this.text);
        if ((old == null) ? text!=null : !old.equals(text))
            morph();
    public int getMaxWidth() {
        return maxWidth;
    public void setMaxWidth(int maxWidth) {
        if (maxWidth <= 0)
            throw new IllegalArgumentException();
        int old = this.maxWidth;
        this.maxWidth = maxWidth;
        firePropertyChange("maxWidth", old, this.maxWidth);
        if (old !=  this.maxWidth)
            morph();
    public boolean isJustified() {
        return justify;
    public void setJustified(boolean justify) {
        boolean old = this.justify;
        this.justify = justify;
        firePropertyChange("justified", old, this.justify);
        if (old != this.justify)
            repaint();
    public Dimension getPreferredSize() {
        return paintOrGetSize(null, getMaxWidth());
    public Dimension getMinimumSize() {
        return getPreferredSize();
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        paintOrGetSize((Graphics2D)g, getWidth());
    private Dimension paintOrGetSize(Graphics2D g, int width) {
        Insets insets = getInsets();
        width -= insets.left + insets.right + margin.left + margin.right;
        float w = insets.left + insets.right + margin.left + margin.right;
        float x = insets.left + margin.left, y=insets.top + margin.top;
        if (width > 0 && text != null && text.length() > 0) {
            AttributedString as = new AttributedString(getText());
            as.addAttribute(TextAttribute.FONT, getFont());
            AttributedCharacterIterator aci = as.getIterator();
            LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
            float max = 0;
            while (lbm.getPosition() < aci.getEndIndex()) {
                TextLayout textLayout = lbm.nextLayout(width);
                if (g != null && isJustified() && textLayout.getVisibleAdvance() > 0.80 * width)
                    textLayout = textLayout.getJustifiedLayout(width);
                if (g != null)
                    textLayout.draw(g, x, y + textLayout.getAscent());
                y += textLayout.getDescent() + textLayout.getLeading() + textLayout.getAscent();
                max = Math.max(max, textLayout.getVisibleAdvance());
            w += max;
        return new Dimension((int)Math.ceil(w), (int)Math.ceil(y) + insets.bottom + margin.bottom);

Similar Messages

  • Word wrap with jLabel

    Is it possible to word-wrap text in a jLabel field? If not, what would be a good choice of component?

    displayArea.setLineWrap (true);
    displayArea.setWrapStyleWord (true);I thought it wasn't added automatic.
    Kind regards,
      Levi

  • Word Wrapping JLabel

    I'm having trouble getting JLabel's to word wrap. I've tried using html tags. Is there any way I ca do this? What I'm trying to do is read in from a file, get Questions and Answers, and display quesitons and answers to a JLabel using setText(). The dimensions are (400, 450) but even with html tags on the text I'm setting, it just runs right off the panel.
    Any suggestions would be much appreciated.
    Thanks,

    Below is my JTextArea. As you can see I have it set for 2 rows and 40 col. When I run the program, it's still just one line of text straight off my panel.
    Do you see anything I'm missing here?
                quesJTextArea = new JTextArea("",2,40);
                quesJTextArea.addMouseListener(this);
                quesJTextArea.setLineWrap(true);
                quesJTextArea.setWrapStyleWord(true);
                quesJTextArea.setEditable(false);
                quesJTextArea.setBackground(Color.gray);

  • JLabel Word Wrap

    I'm building a simple chat application to work on my network programming skills. I ran into an issue that I can't quite find a solution to.
    I Have a JPanel inside of a JScrollPane, and inside of it JLabels with the messages received are added as they come. I would like the JLabels to wrap the text after it reaches a certain width. Here's the testing code I'm using for this:
    import java.awt.*;
    import javax.swing.*;
    class ChatBody {
         public static Container createChatBody() {
              JPanel body = new JPanel(new GridBagLayout());
              GridBagConstraints c = new GridBagConstraints();
              c.fill = GridBagConstraints.BOTH;
              c.weightx = 1.0;
              c.weighty = 1.0;
              JPanel messages = new JPanel();
              JScrollPane messagesPane = new JScrollPane(messages);
              messagesPane.setPreferredSize(new Dimension(608, 478));
              messagesPane.setBorder(BorderFactory.createLineBorder(Color.black));
              messagesPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              JLabel messageOne = new JLabel("This is a label that I'm going to make really long to test the wrapping abilities of a JLabel/JPanel/JScrollPane. This needs to be really long so it will reach the end of the scroll pane and *hopefully* wrap on it's own, so I won't have to do any work =D");
              messages.add(messageOne);
              c.gridx = 0;
              c.gridy = 0;
              body.add(messagesPane, c);
              return body;
    }Please note I took some irrelevant code out.
    Is there a method or something to make JLabels word wrap? Or will I have to be creative and make something up?
    Edit: I don't know if this is relevant, but this is the class with the main() method:
    import java.awt.*;
    import javax.swing.*;
    class JavaChat {
         public static void createChatWindow() {
              JFrame frame = new JFrame("Java Chat");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setMinimumSize(new Dimension(800, 600));
              //frame.setJMenuBar();
              frame.getContentPane().add(ChatBody.createChatBody());
              frame.pack();
              frame.setVisible(true);
         public static void main(String args[]) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createChatWindow();
    }That's needed for anyone that needs to compile my code for some reason.
    Edited by: shadowayex on Dec 24, 2009 1:47 PM

    Wrapping is not support in a JLabel.
    Most people would use either a JTextArea or JTextPane which do support wrapping.

  • Word wrapping incorrect inside JTextPane on MAC 0.5/10.4 and Linux OS

    Hello java-dev team,
    In my application, I am using JTextPane as a text editor to create RTF text. The problem I observed with the JTextPane on MAC OS and Linux OS flavors (I tested on Ubuntu 8.04) is: whenever I am changing any of the text property (font color, font name, font style like bold, italic or underline) and then enter the characters without providing space, the whole word gets wrapped to the next line from the point where exactly the property change starts i.e. the new formatted text is jumped to the next line from the starting point of formatting.
    My requirement is, as I am not adding any space character while changing the property, the characters should be entered in the sequence and should come to new line as per normal word-wrap rule.
    Can anybody help me out in this regards with some solution as it’s a very urgent requirement?
    Below I am also providing the sample code to check the behavior. There is no dynamic facility to change the property in the below code but I am providing the text with multiple formatting settings through code itself. To reproduce the above issue, just type the characters using keyboard in between characters with changed text properties and you can see the whole word jumping to new line.
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.text.MutableAttributeSet;
    import javax.swing.text.SimpleAttributeSet;
    import javax.swing.text.StyleConstants;
    import javax.swing.text.StyledDocument;
    import javax.swing.text.StyledEditorKit;
    public class TestWrapping {
         JScrollPane scroll;
         JTextPane edit;
         public TestWrapping()  throws Exception {
              final JFrame frame=new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              edit=new JTextPane()
                   public void setSize(Dimension d)
                        if (d.width < getParent().getSize().width)
                             d.width = getParent().getSize().width;
                        super.setSize(d);
                   public boolean getScrollableTracksViewportWidth()
                        return false;
              edit.setPreferredSize(new Dimension(150,150));
              edit.setSize(150,150);
              edit.setEditorKit(new StyledEditorKit());
              scroll=new JScrollPane(edit);
              edit.getDocument().insertString(0,"11111111111111222222222222222222222222222222222222222",null);
              MutableAttributeSet attrs=new SimpleAttributeSet();
              StyleConstants.setBold(attrs,true);
              ((StyledDocument)edit.getDocument()).setCharacterAttributes(30,5,attrs,false);
              StyleConstants.setUnderline(attrs,true);
              ((StyledDocument)edit.getDocument()).setCharacterAttributes(35,5,attrs,false);
              StyleConstants.setFontSize(attrs,25);
              ((StyledDocument)edit.getDocument()).setCharacterAttributes(40,5,attrs,false);
              frame.getContentPane().add(scroll);
              frame.setBounds(0,0,150,150);
              frame.show();
         public static void main(String[] args) throws Exception {
              new TestWrapping();
    }The same functionality works fine on Windows XP and problem is observed on MAC OS 10.4/10.5, Ubuntu 8.04. I am using jdk1.5 on both the platforms. I tested using jdk 6.0 on Ubuntu 8.04, and the problem is easily reproducible. I placed a query in the respective OS forums also but did not receive any replies. I also searched the sun’s bug database, but could not find any bug addressing the mentioned problem correctly. I also logged issue at bugs.sun.com and was assigned internal review ID of 1480019 for this problem.
    If you need any additional information, please let me know.
    Thanks in advance.
    Regards,
    VPKVL

    VPKVL wrote:
    Hi All,
    Just want to update that when I checked this issue with JDK1.6 on Ubuntu 8.04, I am unable to reproduce the issue. Everything works as expected. But problem continues on MAC 10.5. So can anybody help me out in coming out of this issue on MAC 10.5.
    Thanks in advance.The only thing I can suggest is that you open a bug (radar) with apple ( developer.apple.com ), and then wait at least 12 months for Apple to get around to fixing it :s

  • Datagrid column header word wrap issue

    Hi All,
    I'm passing dynamic text to a datagrid column header. The word wrap is true but it's not working.
    Any ideas how to fix this issue?
    DataGridColumn headerText="{myVar.text} Total" headerWordWrap="true"
    Thanks
    Johnny

    @Johnny,
    Try to make use of the headerRenderer property and use <mx:Text /> control as a renderer so that your headerText gets wrapped..
    Thanks,
    Bhasker
    Message was edited by: BhaskerChari

  • Resizing ListCellRenderers using JTextArea and word wrap

    Hi,
    I'm trying to create a ListCellRenderer to draw nice cells for a JList. Each cell has a one line title and a description of variable length. So, I create a custom ListCellRenderer, which consists of a JPanel containing a JLabel for the title and a JTextArea for the description. I set the JTextArea to do wrapping on word boundried and it all almost works.
    But, the list cells don't resize to accomodate the variable height of the cells. They show only 1 line for the title and 1 line for the description.
    I have seen a few threads relating to this including the article, "Multi-line cells in JTable in JDK 1.4+" in the Java Specialists' Newsletter, which seems to do a similar trick for JTables. But so far nothing I've tried works.
    Curiously, using println debugging, my getListCellRenderer method seems to get called for each cell twice while my GUI is being drawn. It looks to me like the TextUI view that draws the JTextArea seems to do the word wrapping after the first set of getListCellRenderer calls. But, it's the first set of calls that seems to establish the layout of the list.
    Any help would be appreciated. I've pulled out quite enough hair over this one.
    -chris
    package bogus;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Font;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.*;
    public class CellRendererTest {
         public static void main(String[] args) {
              final CellRendererTest test = new CellRendererTest();
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        test.createGui();
         public void createGui() {
              JFrame frame = new JFrame("Testing Bogus ListCellRenderer");
              JList list = new JList(createBogusListItems());
              list.setCellRenderer(new MyListCellRenderer());
              frame.add(list);
              frame.setSize(200, 400);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         private MyListItem[] createBogusListItems() {
              List<MyListItem> items = new ArrayList<MyListItem>();
              items.add(new MyListItem("First item", "This is a nice short description."));
              items.add(new MyListItem("Another one", "This is a longer description which might take up a couple of lines."));
              items.add(new MyListItem("Next one", "This is a ridiculously long description which is total gibberish." +
                        "Blah blah blabber jabber goo. Blither blather bonk. Oink boggle gaggle ker-plunk."));
              items.add(new MyListItem("No Desc", null));
              items.add(new MyListItem("Last one", "Boink!"));
              return items.toArray(new MyListItem[items.size()]);
         static class MyListCellRenderer extends JPanel implements ListCellRenderer {
              private JLabel title;
              private JTextArea desc;
              // hack to see if this is even possible
              private static int[] rows = {1, 2, 3, 0, 1};
              public MyListCellRenderer() {
                   setLayout(new BorderLayout());
                   setBorder(BorderFactory.createEmptyBorder(6, 4, 6, 4));
                   setOpaque(true);
                   title = new JLabel();
                   title.setFont(new Font("Arial", Font.ITALIC | Font.BOLD, 11));
                   add(title, BorderLayout.NORTH);
                   desc = new JTextArea();
                   desc.setFont(new Font("Arial", Font.PLAIN, 9));
                   desc.setOpaque(false);
                   desc.setWrapStyleWord(true);
                   desc.setLineWrap(true);
                   add(desc, BorderLayout.CENTER);
              public Component getListCellRendererComponent(JList list, Object value,
                        int index, boolean isSelected, boolean cellHasFocus) {
                   MyListItem item = (MyListItem)value;
                   title.setText(item.title);
                   if (item.description != null && item.description.length() > 0) {
                        desc.setText(item.description);
                        desc.setVisible(true);
                   else {
                        desc.setVisible(false);
                   // uncomment next line to to somewhat simulate the effect I want (hacked using the rows array)
                   // desc.setRows(rows[index]);
                   if (isSelected) {
                        setBackground(list.getSelectionBackground());
                        setForeground(list.getSelectionForeground());
                   else {
                        setBackground(list.getBackground());
                        setForeground(list.getForeground());
                   return this;
         static class MyListItem {
              String title;
              String description;
              public MyListItem(String title, String description) {
                   this.title = title;
                   this.description = description;
    }

    This seems to work
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Insets;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.text.View;
    public class CellRendererTest {
         int WIDTH = 220;
         public static void main(String[] args) {
              final CellRendererTest test = new CellRendererTest();
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        test.createGui();
         public void createGui() {
              JFrame frame = new JFrame("Testing Bogus ListCellRenderer");
              JList list = new JList(createBogusListItems());
              final MyListCellRenderer renderer = new MyListCellRenderer();
              list.setCellRenderer( renderer );
              JScrollPane listScrollPane = new JScrollPane(list);
              frame.add(listScrollPane);
              frame.setSize(WIDTH, 400);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         private MyListItem[] createBogusListItems() {
              List<MyListItem> items = new ArrayList<MyListItem>();
              items.add(new MyListItem("First item", "This is a nice short description."));
              items.add(new MyListItem("Another one", "This is a longer description which might take up a couple of lines."));
              items.add(new MyListItem("Next one", "This is a ridiculously long description which is total gibberish." +
                        "Blah blah blabber jabber goo. Blither blather bonk. Oink boggle gaggle ker-plunk."));
              items.add(new MyListItem("No Desc", null));
              items.add(new MyListItem("Last one", "Boink!"));
              items.add(new MyListItem("Ooops this one breaks things by being longer than my fixed width", "Blabber babble gibber flipper flop."));
              return items.toArray(new MyListItem[items.size()]);
         static class MyListCellRenderer extends JPanel implements ListCellRenderer {
              public JLabel title;
              public JTextArea desc;
              Color altColor = new Color(0xeeeeee);
              public MyListCellRenderer() {
                   setLayout(new BorderLayout());
                   setBorder(BorderFactory.createEmptyBorder(6, 4, 6, 4));
                   setOpaque(true);
                   title = new JLabel();
                   title.setFont(new Font("Arial", Font.ITALIC | Font.BOLD, 11));
                   add(title, BorderLayout.NORTH);
                   desc = new JTextArea();
                   desc.setFont(new Font("Arial", Font.PLAIN, 9));
                   desc.setOpaque(false);
                   desc.setWrapStyleWord(true);
                   desc.setLineWrap(true);
                   add(desc, BorderLayout.CENTER);
              public Component getListCellRendererComponent(JList list, Object value,
                        int index, boolean isSelected, boolean cellHasFocus) {
                   Insets insets = desc.getInsets();
                int rendererLeftRightInsets = insets.left + insets.right + 8;  // 8 from panel border
                int topDownInsets = insets.top + insets.bottom;
                int listWidth = list.getWidth();
                int viewWidth = listWidth;
                   int scrollPaneLeftRightInsets = 0;
                   JScrollPane scroll = (JScrollPane) SwingUtilities.getAncestorOfClass( JScrollPane.class, list );
                   if ( scroll != null && scroll.getViewport().getView() == list ) {
                        Insets scrollPaneInsets = scroll.getBorder().getBorderInsets(scroll);
                     scrollPaneLeftRightInsets = scrollPaneInsets.left + scrollPaneInsets.right;
                     listWidth = scroll.getWidth() - scrollPaneLeftRightInsets;
                     JScrollBar verticalScrollBar = scroll.getVerticalScrollBar();
                     if (verticalScrollBar.isShowing()) {
                         listWidth -= verticalScrollBar.getWidth();
                     viewWidth = listWidth - rendererLeftRightInsets;
                   MyListItem item = (MyListItem)value;
                   title.setText(item.title);
                   if (item.description != null && item.description.length() > 0) {
                        desc.setText(item.description);
                        desc.setVisible(true);
                        View rootView = desc.getUI().getRootView(desc);
                     rootView.setSize( viewWidth, Float.MAX_VALUE );
                    float yAxisSpan = rootView.getPreferredSpan(View.Y_AXIS);
                        Dimension preferredSize = new Dimension( viewWidth, (int)yAxisSpan + topDownInsets );
                        desc.setPreferredSize( preferredSize );
                   } else {
                        desc.setVisible(false);
                   title.setPreferredSize( new Dimension( viewWidth, title.getPreferredSize().height ) );
                   // uncomment next line to to somewhat simulate the effect I want (hacked using the rows array)
                   //desc.setRows(rows[index]);
                   if (isSelected) {
                        setBackground(list.getSelectionBackground());
                        setForeground(list.getSelectionForeground());
                   else {
                        if (index % 2 == 0)
                             setBackground(altColor);
                        else
                             setBackground(list.getBackground());
                        setForeground(list.getForeground());
                   return this;
         static class MyListItem {
              String title;
              String description;
              public MyListItem(String title, String description) {
                   this.title = title;
                   this.description = description;
    }

  • Webforms - Wrap Text/Word Wrap for Column Headings

    I have some member aliases that are set as my webform's column headings, but they are fairly long. Setting the column width to a custom value that fits most of the text in the heading makes the form very wide and ugly to work with. I don't see any option to Wrap Text or use Word Wrap in the column headings. Is there any way to do this?
    Thanks!

    Hi,
    I am not aware of any option which allows you to wrap the text, it may be possible customizing the [CSS |http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/html_hp_admin/ch12s03.html] though to be honest I am not even sure about that and even if it was possible it would apply to all apps.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How to word wrap within text field

    I've created a form with a text field but when filling the form out, the words don't word wrap, but merely go in a single line across the text box field. 
    When can I format the text box to word wrap?
    tks

    I have set my text fields to multi line and the text wraps but it only starts about halfway down the text box.  Please help, this is getting frustrating...

  • How can I turn off word wrap in the View Source output?

    I'm trying to extract HTML from Word and one way to do that is to save the Word file as a .htm file and then View Source in a browser and copy that. But the words are wrapped in the View Source file. I want each paragraph to be all on one line. Is there a setting for the View Source feature that will turn off word wrap?
    Once I have that done and copied into a plain text editor, I will use Search>Replace to get rid of all the stuff Word puts there and just end up with the simple paragraph tags at the end of each paragraph, all on one line.

    You can disable wrapping and syntax highlighting in the View menu in the Edit > View Source window.

  • Looking for a word processor without word wrap, text edit doesn't cut it

    I'm looking for a word processor without word wrap, text edit doesn't work. In text edit, it automatically scoots my text over to the next line but I just want it to keep going with a horizontal scrollbar. Is there a text editor I can download from the app store or can I get textedit to work somehow where it uses a horizontal scroll bar instead of entering text to the next line?

    Hi,
    thought TextWrangler can do it.
    But it seems that the 'no word-wrap' "feature" isn't that much wanted anymore.
    Maybe one of these http://www.macupdate.com/find/mac/text%20editor can do it.
    Regards
    Stefan

  • Read Only TextAreas with Carriage Return, Line Breaks and Word Wrapping

    Hi all,
    I know there are a few posts around this subject but I cannot find the answer to the exact problem I have.
    I have a page that has a 'TextArea with Character Counter' (4000 Chars) that is conditionally read only based on the users credentials (using the 'Read Only' attributes of the TextArea item).
    When the field is editable (not Read Only) everything works fine but when I make the field Read Only I start to have problems:
    The first problem is that the Carriage Return and Line Breaks are ignored and the text becomes one continuos block. I have managed to fix this by adding pre and post element text of pre and /pre tags. This has made the Carriage Return and Line Breaks word nicely and dispaly correctly.
    However, it has introduced a second problem. Long lines, with no Carriage Returns or Line Breaks, now extend to the far right of the page with no word wrapping, making my page potentially 4000+ characters wide.
    How can I get the field to be display only, with recognised Carriage Returns and Line Breaks, and Word Wrapping inside a fixed width of, say, 150 characters?
    Many thanks,
    Martin

    Hi,
    Just a cut and paste of yours with the field name changed:
    htp.p('<script>');
    htp.p('$x("P3_COMMENTS").readonly=true;');
    htp.p('</script>');I also have the following in the page HTML Header, could they be conflicting?
    <script type="text/javascript" language="JavaScript">
    function setReleaseToProd(wpTypeCode){
       //setReleaseToProd($v(this))
      var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=set_release_to_prod',0);
      get.addParam('x01',wpTypeCode);
      gReturn = get.get();
      if(gReturn) {
         $s('P3_RELEASE_TO_PROD',gReturn);
      get = null;
    </script>I am a long way from knowing much about Javascript (this page code was written by someone else) so all help is much appreciated.
    Martin

  • Word Wrap with a Vertical Grid

    I've got a vertical grid with my headers in the left column and descriptive text in the column immediately to the right.  I'd like to have the descriptive text word wrap but checking the word wrap box on the layout tab doesn't seem to have any effect.
    Any ideas?  I'm using 11.5 SP3

    I'm not sure if it will work with the iGrid in a vertical orientation, but have you tried setting the RowHeight to something like 20 or 30 instead of the default of 0?  This setting will auto adjust the grid lines based upon the font-size, but you may need to force it to a certain height in order for the wrapping to work.
    Regards,
    Jeremy

  • How to make items in a list word wrap as needed and be variable heights

    I am trying to build a custom itemrenderer for the List control.  The items in the list are variable lengths of text, some of the text items will have different colors determined at runtime base on some criteria (this works fine now with my custom itemrenderer).  What I need is for the items to word wrap, and therefore for the list to display items of varying heights.  Is this possible to do?  All my attempts seem to have failed.  If I can't do this with an item renderer any suggestions about how to do this?  Thanks very much in advance to any of you gurus who are able to help me.

    Trick here is not to specify any height for the renderer so that Flex will determine the height according to the content. Also set the variableRowHeight="true"
    Here is a simple example
    <mx:ArrayCollection id="dp">
            <mx:Array>
                <mx:Object label="some very long text"/>
                <mx:Object label="some very loooooooooooooooooooooooooooooooooong text"/>
                <mx:Object label="some very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text"/>
                <mx:Object label="some very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text"/>
                <mx:Object label="some very long text"/>
            </mx:Array>
        </mx:ArrayCollection>
        <mx:List dataProvider="{dp}" variableRowHeight="true">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:Canvas width="100%">
                        <mx:Text width="100%" text="{data.label}"/>
                    </mx:Canvas>
                </mx:Component>
            </mx:itemRenderer>
        </mx:List>

  • Force word wrap in JTextPane (using HTMLEditorKit)

    Hi!
    I have a JTextPane on a JScrollPane inside a JPanel. My text pane is using HTMLEditorKit.
    I set the scrolling policies of my JScrollPane to: JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER.
    I did not find in JTextPane�s API any relevant property I can control word-wrapping with (similar to JTextArea�s setLineWrap) and I have tried a few things to force word-wrapping but nothing worked...
    What happens is my text is NOT being wrapped (even though there is no horizontal scrolling) and typed characters (it is an enabled editable text componenet) are being added to the same long line�
    I�d like to force word-wrapping (always) using the vertical scroll bar whenever the texts extends for more then one (wrapped) line.
    Any ideas?
    Thanks!!
    Message was edited by:
    io1

    Your suggestion of using the example only holds if it fits the requirements of the featureDid your questions state anywhere what your requirement was?
    You first questions said you had a problem, so I gave you a solution
    You next posting stated what your where currently doing, but it didn't say it was a requirement to do it that way. So again I suggested you change your code to match the working example.
    Finally on your third posting you state you have some server related issues causing the requirement which I did not know about in my first two postings.
    State your problem and special requirments up front so we don't waste time quessing.
    I've used code like this and it wraps fine:
    JTextPane textPane = new JTextPane();
    textPane.setContentType( "text/html" );
    HTMLEditorKit editorKit = (HTMLEditorKit)textPane.getEditorKit();
    HTMLDocument doc = (HTMLDocument)textPane.getDocument();
    textPane.setText( "<html><body>some long text ...</body></html>" );
    JScrollPane scrollPane = new JScrollPane( textPane );If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

Maybe you are looking for

  • Follow-up on Ravi's User Exits example

    Hi, Ravi's user exit example: You have a content data source with fields say customer,sale org, profit center and amount. You wish to add sales manager to this extractor. You <b><u>locate</u></b> the table and <u><b>field name and append that field t

  • Why can I no longer download podcast directly to my first gen touch.

    Using download "get more episodes" feature over wifyno longer works for first gen iPod touch.  I can add podcasts using iTunes. I can also add apps using wifi no problem

  • Installtion of Informatic Power Center 9.0.1 in Solaris Sprac 64 Bit

    I want to know how to configure and which file required for Informatic Power Center 9.0.1 in Solaris Sprac 64 Bit setup. Please help to how configure server and client in solaris sprac .

  • PO message type Error

    Hi All I have configured a new message type ZCTL for EDI. however i find all configs in place still i get an error of NO COMMUNICATION DATA MAINTAINED FOR TRANSMISSION MEDIUM 6. I have checked MN06 for the key combinations and it maintained correctly

  • Lobby Admin for guest account creation - Automation of account creation

    hello all, i'm sure the creation of guest accounts on the lobby admin page is a painful process for all involved - for us, it involves a process like this: visitor asks for wifi > receptionist phones IT > IT creates account> IT phones receptionist wi