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.


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

Results 1 to 2 of 2

Thread: printing in java; missing spaces

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Thanked 0 Times in 0 Posts

    Default printing in java; missing spaces

    I'm trying to print a swing component to paper. It's basically an extended JPanel which hosts (among other things) multiple JTextFields. These fields look correct when viewed on the screen, but when printed to paper, the text in the fields is not printed correctly... in some fields, the spaces in between words is quite large, in other fields, it is like there are no spaces at all; every word is jammed right beside the previous word.

    I've checked and double / triple checked the component, and the fields all definitely have spaces in them... looks 100% correct when viewed on the screen, just prints incorrectly.

    I've played with the FRACTIONALMETRICS hints in the Graphics class, as well as antialiasing and a few other rendering hints, and nothing has any effect on what I'm seeing.

    Printing to other printers also has no effect, and this problem appears on Sun's JVM in both windows + linux. Switching fonts will just shuffle which textfields the problem occurs in, but doesn't actually solve the problem.

    Any ideas?

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 827 Times in 770 Posts
    Blog Entries

    Default Re: printing in java; missing spaces

    Can you post a short snippet of code that reproduces the problem? Never encountered this problem, but I am guessing this might have to do with the width of each component and the printing trying to jam all those words into a small space. A small self contained example might help test this

Similar Threads

  1. [SOLVED] Printing Data in JAVA
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: October 15th, 2010, 01:22 PM
  2. Cant get spaces
    By Ksmartman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 13th, 2010, 07:06 AM
  3. [SOLVED] Printing Array without printing empty elements
    By CarlMartin10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 12th, 2010, 02:41 AM
  4. How to remove the in-between spaces in a String? Please help.
    By marksquall in forum Java Theory & Questions
    Replies: 2
    Last Post: February 4th, 2010, 03:19 PM
  5. [SOLVED] How to Put Spaces in the Output of Passed Arguments?
    By EmSaint in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 25th, 2010, 03:04 PM