Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Change Font/Orientation for jTextArea print

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Change Font/Orientation for jTextArea print

    I wish to print the content of a JTextArea. I know I can do this with textarea.print().
    However, I wish to print in a different font, font size and orientation from that of the JTextArea itself. I have been able to change the orientation by setting print attributes
    PrintRequestAttributeSet printAttributes =
    new javax.print.attribute.HashPrintRequestAttributeSet ();
    printAttributes.add(javax.print.attribute.standard .OrientationRequested.LANDSCAPE);
    and then using the textarea.print() method that allows me to set attributes. However, I haven't found any way to set the font and font size. Any Ideas?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Change Font/Orientation for jTextArea print

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Rather than printing the contents of the text area directly, obtain the text area's contents as a String and pass that to code that will configure it or the printer's settings as needed, and then print it.

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Change Font/Orientation for jTextArea print

    Your solution implies that I must do all the pagination and formatting that the JTextArea print method does for me. All I want to do is to change the Font & Size and use the supplied JTextArea print routine with minimal additions.

Similar Threads

  1. [SOLVED] JTextArea font/character count issue
    By psychobeagle12 in forum AWT / Java Swing
    Replies: 7
    Last Post: April 25th, 2012, 06:17 PM
  2. Re: How to Change JTextArea font, font size and color
    By binokyo10 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 5th, 2012, 12:12 PM
  3. How to Change JTextArea font, font size and color
    By Flash in forum Java Swing Tutorials
    Replies: 7
    Last Post: January 14th, 2012, 10:47 PM
  4. Console Font Change
    By Jsith96 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: October 18th, 2011, 11:37 PM
  5. How to Change JTextArea font, font size and color
    By Flash in forum Java Code Snippets and Tutorials
    Replies: 4
    Last Post: July 8th, 2008, 01:45 PM

Tags for this Thread