Results 1 to 4 of 4

Thread: Bolding text in a JTextArea

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Bolding text in a JTextArea

    What are the syntax for Bolding text in a JTextArea . I know that JTextArea do not word wrap when ever you type the text in it and it's multi-line area that displays plain text. What is difference between JTextPane and JTextArea.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Bolding text in a JTextArea

    You are wrong in saying that JTextArea does not support word wrapping. javax.swing.JTextPane class represents a significant improvement over AWT’s TextArea. JTextArea is different in that it doesn't manage scrolling, but implements the swing Scrollable interface.Using the methods setLineWrap(..) and setWrapStyleWord(..) you can control whether you want word wrap and in what manner you want to do it.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Bolding text in a JTextArea

    Code:
    import javax.swing.JTextArea;
    import javax.swing.JFrame;
    
    import java.awt.BorderLayout;
    import java.awt.Font;
    
    public class bold
    {
    public static void main(String[]args)
    {
     //Create text area using JTextArea
     JTextArea Area=new JTextArea();
    
     //Set line wrap to true
     Area.setLineWrap(true);
    
    
     Font AreaFont=new Font(Area.getFont().getName(),Font.BOLD,Area.getFont().getSize());
    
     Area.setFont(AreaFont);
    
     JFra frame=new JFra("Set text bold");
    
     
     frame.setLayout(new BorderLayout());
    
    
     frame.add(textArea);
    
    
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
     frame.setSize(500,600);
     
     frame.setVisible(true);
    }

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Bolding text in a JTextArea

    textArea.setForeground(Color.blue); changes the color or you can use
    Code:
    Font font = new Font("Verdana", Font.BOLD, 12);
    JVtxt.setFont(font);
    JVtxt.setForeground(Color.BLUE);

Similar Threads

  1. Replies: 5
    Last Post: 28-02-2011, 08:23 PM
  2. BlackBerry Torch TEXT message icon not showing text messages
    By rOSAMOND in forum Portable Devices
    Replies: 8
    Last Post: 17-10-2010, 01:04 AM
  3. JTextArea for input text from the user
    By liatB in forum Software Development
    Replies: 1
    Last Post: 17-03-2010, 08:37 PM
  4. Add scrollbar to JTextArea
    By Captain Carrot in forum Software Development
    Replies: 5
    Last Post: 10-03-2010, 09:39 AM
  5. JTextArea class of java
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 11:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,417,160.67584 seconds with 16 queries