Swings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #16
    Originally posted by gaya3
    Jos, i tried with String buffer concept as follows..
    StringBuffer strbuff = new StringBuffer();
    String fields[] = {"Fruits"};
    while //loop
    {
    strbuff .append(String_ from_resultset) ; ---------> I tokenized from the resultset
    strbuff.append( "/n");
    data[i][1] = strbuff.toStrin g();
    }
    JTable jtable = new JTable(data,fie lds);
    still facing the same problem Jos..:-(

    -Thanks & Regards,
    Hamsa
    You have to read up on TableCellRender ers; the default one is just a 'rubber stamp'
    of a JLabel and JLabels don't interpret '\n' characters at all so your three string
    parts all end up on one line. A silly trick would be to feed the JLabel (actually
    the renderer) an html string; something like this:

    [code=java]
    String columnFromDB= "apple orange strawberry";
    columnFromDB= columnFromDB.re placeAll(" ", "<br>");
    columnFromDB= "<html>"+column FromDB+"</html>";
    [/code]

    This code snippet effectively turns this:

    "apple orange strawberry"

    into this:

    "<html>apple<br >orange<br>stra wberry</html>"

    and it will be rendered as three lines but it will still be one single column value.

    kind regards,

    Jos

    Comment

    • gaya3
      New Member
      • Aug 2007
      • 184

      #17
      Originally posted by JosAH
      You have to read up on TableCellRender ers; the default one is just a 'rubber stamp'
      of a JLabel and JLabels don't interpret '\n' characters at all so your three string
      parts all end up on one line. A silly trick would be to feed the JLabel (actually
      the renderer) an html string; something like this:

      [code=java]
      String columnFromDB= "apple orange strawberry";
      columnFromDB= columnFromDB.re placeAll(" ", "<br>");
      columnFromDB= "<html>"+column FromDB+"</html>";
      [/code]

      This code snippet effectively turns this:

      "apple orange strawberry"

      into this:

      "<html>apple<br >orange<br>stra wberry</html>"

      and it will be rendered as three lines but it will still be one single column value.

      kind regards,

      Jos

      Thanks Jos..

      -Thanks & Regards,
      Hamsa

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #18
        Originally posted by gaya3
        Thanks Jos..

        -Thanks & Regards,
        Hamsa
        I was starting to fear that this thread was starting to obey the law of long threads.

        Comment

        Working...