Escape codes not working

Discussion in 'Java' started by Steve, Jun 21, 2004.

  1. Steve

    Steve Guest

    Hi all,

    Why is it that the statement:

    Label l = new Label("This \n Test should work");

    shows the label with a block (as in, square) character instead of the linefeed?
     
    Steve, Jun 21, 2004
    #1
    1. Advertising

  2. Steve wrote:

    > Why is it that the statement:
    >
    > Label l = new Label("This \n Test should work");
    >
    > shows the label with a block (as in, square) character instead of the linefeed?


    From the API doc of java.awt.Label:

    "A label displays a single line of read-only text."
     
    Michael Borgwardt, Jun 21, 2004
    #2
    1. Advertising

  3. Steve

    Fedor Guest

    Steve <> wrote:
    > Hi all,
    >
    > Why is it that the statement:
    >
    > Label l = new Label("This \n Test should work");
    >
    > shows the label with a block (as in, square) character instead of the linefeed?


    Have you tried carriage return (\r) or both \n and \r ?


    f
     
    Fedor, Jun 21, 2004
    #3
  4. Steve wrote:
    > Why is it that the statement:
    >
    > Label l = new Label("This \n Test should work");
    >
    > shows the label with a block (as in, square) character instead of the linefeed?


    Because it is not supported. Use a TextArea instead, or use Swing and
    HTML in the label.

    /Thomas
     
    Thomas Weidenfeller, Jun 21, 2004
    #4
  5. Steve

    Roedy Green Guest

    On 21 Jun 2004 05:18:39 -0700, (Steve) wrote or
    quoted :

    >Label l = new Label("This \n Test should work");
    >
    >shows the label with a block (as in, square) character instead of the linefeed?


    Because Label is not smart enough, or rather the underlying GUI is not
    smart enough. To get that effect you need Swing JLabel and use HTML
    and encode your linefeed as <br>

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jun 21, 2004
    #5
  6. Steve

    Jacob Guest

    Roedy Green wrote:

    > On 21 Jun 2004 05:18:39 -0700, (Steve) wrote or
    > quoted :
    >
    >
    >>Label l = new Label("This \n Test should work");
    >>
    >>shows the label with a block (as in, square) character instead of the linefeed?

    >
    >
    > Because Label is not smart enough, or rather the underlying GUI is not
    > smart enough. To get that effect you need Swing JLabel and use HTML
    > and encode your linefeed as <br>


    Label is defined to be one line, so this has nothing
    to do with lack of smartness.
    Don't use HTML; Google for "MultiLineLabel" instead.
     
    Jacob, Jun 22, 2004
    #6
  7. In article <HhSBc.9091$>,
    Jacob <> wrote:
    >
    >Label is defined to be one line, so this has nothing
    >to do with lack of smartness.


    Well, if you ask me, it would be a lot smarter for Label to support
    multiline than not to.

    >Don't use HTML; Google for "MultiLineLabel" instead.


    Why, when JLabel already does this anyway? Does MultiLineLabel do
    something that JLabel can not?

    Cheers
    Bent D
    --
    Bent Dalager - - http://www.pvv.org/~bcd
    powered by emacs
     
    Bent C Dalager, Jun 22, 2004
    #7
  8. Steve

    Roedy Green Guest

    On Tue, 22 Jun 2004 10:42:15 +0200, Jacob <> wrote or
    quoted :

    >Label is defined to be one line, so this has nothing
    >to do with lack of smartness.


    But if you ponder WHY Label was defined that way, the reason is the
    that Label is a heavyweight component. It is limited by what
    heavyweight Label components in various GUIs can do. In general, they
    are not smart enough to handle multiline labels. Thus, Java had to
    limit Label to the lowest common denominator.

    In Swing, JLabel is a lightweight component. It thus does not matter
    what the underlying GUI does, so JLabel can even be smart enough to
    render HTML or Images.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jun 22, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bert Sierra

    Escape codes in XML?

    Bert Sierra, Jul 22, 2004, in forum: XML
    Replies:
    1
    Views:
    5,912
    Michael Wiedmann
    Jul 22, 2004
  2. Daniel

    unescaping xml escape codes

    Daniel, Aug 10, 2003, in forum: Python
    Replies:
    2
    Views:
    5,244
    Bengt Richter
    Aug 11, 2003
  3. Replies:
    2
    Views:
    2,996
    Malcolm
    Aug 20, 2005
  4. slomo
    Replies:
    5
    Views:
    1,633
    Duncan Booth
    Dec 2, 2007
  5. Krist
    Replies:
    8
    Views:
    7,235
    lightst4r
    Jul 23, 2012
Loading...

Share This Page