Working with JTextArea


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Working with JTextArea

  1. #1
    Join Date
    Oct 2004
    Location
    Chicago
    Posts
    108

    Angry Working with JTextArea

    I am writing a simple text editor, I am having problems with a JTextArea.

    I can enter text and everything is fine, but when I save it into a text file the line breaks are not recognized. If i open that file with notepad it simply shows a box in place of the line break. Also when I load that text file into the JTextArea the boxes are not there, and the line breaks are just not present.

    My second problem is printing. I found a way to print text to the printer, using a print stream, but when I print anything from my TextArea each line is tabbed over.

    Example

    Code:
    Text
          Text
                Text
                      Text

    Is there any way I can fix that, or is there a different way to print text to the default printer?

    Thanks in advance
    Last edited by Wizard1988; 12-06-2005 at 09:33 AM.

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Take a look at the API documentation for JTextArea - you'll see a reference to the "DefaultEditorKit" class of javax.swing.text "for a discussion on how newlines are handled."

    There is a tutorial on text components which you can find at:

    http://java.sun.com/docs/books/tutor...ents/text.html

Similar Threads

  1. Replies: 1
    Last Post: 12-05-2001, 06:12 AM
  2. changing working dir in Java
    By Jim in forum Java
    Replies: 1
    Last Post: 02-18-2001, 01:58 PM
  3. VSS:sharing same working folder without multiple checkouts
    By rahul phatak rahulphatak in forum ASP.NET
    Replies: 0
    Last Post: 06-01-2000, 05:41 PM
  4. Sysinfo not working GetSystemPowerStatus not working
    By Thomas Hauff in forum VB Classic
    Replies: 0
    Last Post: 04-08-2000, 10:15 PM
  5. Sysinfo not working GetSystemPowerStatus not working
    By Thomas Hauff in forum VB Classic
    Replies: 0
    Last Post: 04-08-2000, 10:15 PM

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