Is there a JParagraph


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Is there a JParagraph

  1. #1
    Join Date
    Jun 2004
    Posts
    29

    Is there a JParagraph

    I'm wondering if there's a swing item that's like a JLabel except that it spans many lines, like a JParagraph. If I write

    JLabel L = new JLabel("line 1\nline2");

    What gets displayed in the interface is "line 1line 2" (i.e. the '\n' gets trashed). I'd like to know if there's anything that will take the '\n' into account and span several lines.

    Gib

  2. #2
    Join Date
    Sep 2003
    Posts
    18
    Have a look at JTextArea. This is from the Java 1.4.2 API Specification and sounds exactly like what you're looking for:
    A JTextArea is a multi-line area that displays plain text.

  3. #3
    Join Date
    Jun 2004
    Posts
    14
    JOptionPane automatically parses the \n's to make multiple lines. It probably just uses multiple JLabels.

  4. #4
    Join Date
    Feb 2004
    Posts
    808
    i agree with the JTextArea option..

    if you set its border to null and call setEditable(false), setOpaque(false) then it will look like a JLabel
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center