Poor printing java 1.5

Hi,

I have a problem with printing on java 1.5 on XP. Everything was fine on 1.42, but now the printing stops after a few pages and the text looks poor. There is no error message when the printing stops early.

My swing application has several tabbed panes each of which is added to a Book. Each tab is scaled to fit on the page and is printed on a separate page. Each page will print separately but the text still looks bad. Even removing the scaling doesn抰 help the text.

I disable the double buffering before printing.

I have tried a few different printers and also changing heap sizes 朮mx to 1g but get the same results.

Any ideas on how I can resolve theses problems?

Thanks

[721 byte] By [alan_314a] at [2007-10-3 8:47:27]
# 1

I've been doing some more digging into this.

On 1.5 The print method of the printable class gets called 3000 ~ 10 000 times, On 1.42 it gets called twice. That would explain why printing is so slow and large memory used.

When I change the look and feel to when using 1.5 to Metal , Motif or WindowsClassic the print method is called only twice and the text looks good. Is there a problem with the newer Windows look and feel ?

Also the text on the 1.5 print looks exactly the same as text on 1.42 that has double buffering still on.

Anyone have any ideas?

alan_314a at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...
# 2
Any Suggestions?Can i use the look and feel from 1.42 with 1.5? Whats jar file is it in?Are there any other windows look and feel to try?
alan_314a at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...
# 3

Ok I still have the problem , but have made a small test program as example.

Thanks for any help

TestPrint.java

import java.awt.*;

import javax.swing.UIManager;

public class TestPrint extends javax.swing.JFrame {

/** Creates new form TestPrint */

public TestPrint() {

initComponents();

}

private void initComponents() {

mainJPanel = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

jbPrint = new javax.swing.JButton();

subJPanel = new javax.swing.JPanel();

jLabel2 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jTextArea1 = new javax.swing.JTextArea();

jTextField2 = new javax.swing.JTextField();

jTextArea2 = new javax.swing.JTextArea();

addWindowListener(new java.awt.event.WindowAdapter() {

public void windowClosing(java.awt.event.WindowEvent evt) {

exitForm(evt);

}

});

mainJPanel.setLayout(new java.awt.BorderLayout());

mainJPanel.setBackground(new java.awt.Color(255, 255, 255));

jLabel1.setText("This Text Is OK");

mainJPanel.add(jLabel1, java.awt.BorderLayout.NORTH);

jbPrint.setText("Print");

jbPrint.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jbPrintActionPerformed(evt);

}

});

mainJPanel.add(jbPrint, java.awt.BorderLayout.SOUTH);

subJPanel.setLayout(new java.awt.GridLayout(2, 2));

subJPanel.setBackground(new java.awt.Color(255, 255, 255));

subJPanel.setBorder(new javax.swing.border.TitledBorder("This text is OK"));

jLabel2.setText("This text is not OK");

subJPanel.add(jLabel2);

jTextField1.setText("Text Not OK");

subJPanel.add(jTextField1);

jTextArea1.setText("Text Not OK");

jTextArea1.setBorder(new javax.swing.border.TitledBorder("Text not OK"));

subJPanel.add(jTextArea1);

mainJPanel.add(subJPanel, java.awt.BorderLayout.CENTER);

jTextField2.setText("Text OK");

mainJPanel.add(jTextField2, java.awt.BorderLayout.EAST);

jTextArea2.setText("Text not OK");

jTextArea2.setBorder(new javax.swing.border.TitledBorder("Text OK"));

mainJPanel.add(jTextArea2, java.awt.BorderLayout.WEST);

getContentPane().add(mainJPanel, java.awt.BorderLayout.CENTER);

pack();

}

private void jbPrintActionPerformed(java.awt.event.ActionEvent evt) {

Component[] comps = new Component[1];

comps[0] = mainJPanel;

PrintUtilities3.printComponent(comps,1, 1, 1);

}

/** Exit the Application */

private void exitForm(java.awt.event.WindowEvent evt) {

System.exit(0);

}

public static void main(String args[]) {

try {

UIManager.setLookAndFeel(/*"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"*/UIManager.getSystemLookAndFeelClassName());

} catch (Exception e){

System.out.println("Error: " + e);

}

new TestPrint().show();

}

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JTextArea jTextArea1;

private javax.swing.JTextArea jTextArea2;

private javax.swing.JTextField jTextField1;

private javax.swing.JTextField jTextField2;

private javax.swing.JButton jbPrint;

private javax.swing.JPanel mainJPanel;

private javax.swing.JPanel subJPanel;

}

PrintUtilities3.java

import java.awt.*;

import java.awt.geom.*;

import javax.swing.*;

import java.awt.print.*;

public class PrintUtilities3 {

private Component[] component;

private Component comp;

private int method;

private int pageNum;

private int totalPages;

float scale;

private static int paintcall = 0;

public final static int AS_IS = 0;

public final static int SCALE_TO_FIT = 1;

public final static int BOOK_HEIGHT = 2;

public final static int BOOK_WIDTH = 3;

public static void printComponent(Component[] c, int method, int pageNum, int totalPages) {

new PrintUtilities3(c, method, pageNum, totalPages ).print();

}

private PrintUtilities3(Component[] component, int method, int pageNum, int totalPages) {

this.component = component;

this.method = method;

this.pageNum = pageNum;

this.totalPages = totalPages;

}

private void print(){

System.out.println("Start printing");

PrinterJob printJob = PrinterJob.getPrinterJob();

PageFormat pf = printJob.defaultPage();

Paper paper = new Paper();

paper.setSize(595, 842);

paper.setImageableArea(20 ,20,555, 802);

pf.setPaper(paper);

pf.setOrientation(pf.LANDSCAPE);

paintcall = 0;

Book book = new Book();

for ( int i =0 ; i < component.length; i++){

disableDoubleBuffering(component[i]);

this.comp = component[i];

scale = calculateScale(pf);

book.append(new pagePrinter(i),pf);

}

printJob.setPageable(book);

// show print dialog

if (printJob.printDialog()){

try{

printJob.print();

System.out.println("Finished printing -");

}catch(PrinterException pe){

System.out.println("Error printing: " + pe);

}

}

for ( int i =0 ; i < component.length; i++){

enableDoubleBuffering(component[i]);

}

System.out.println("Finished printing");

}

private float calculateScale(PageFormat pf){

float scl = 1f;

switch(method){

case BOOK_HEIGHT:

scl = (float) pf.getImageableHeight()/comp.getSize().height;

break;

case BOOK_WIDTH:

scl = (float) pf.getImageableWidth()/comp.getSize().width;

break;

case SCALE_TO_FIT:

scl = (float) Math.min(pf.getImageableWidth()/comp.getSize().width,

pf.getImageableHeight()/comp.getSize().height);

break;

case AS_IS:

scl = 1; //no scaling

break;

}

if(scl > 1)

scl = 1; //we only resize the component if it is to large

return scl;

}

public static void disableDoubleBuffering(Component c) {

RepaintManager currentManager = RepaintManager.currentManager(c);

currentManager.setDoubleBufferingEnabled(false);

}

public static void enableDoubleBuffering(Component c) {

RepaintManager currentManager = RepaintManager.currentManager(c);

currentManager.setDoubleBufferingEnabled(true);

}

class pagePrinter implements Printable{

int i;

private pagePrinter(int i ){

this.i = i;

}

public int print(Graphics g, PageFormat pf, int page) {

if (page >= totalPages){

return(NO_SUCH_PAGE);

}

else{

Graphics2D g2 = (Graphics2D)g;

Font f = new Font("Arail", Font.BOLD, 14);

g2.setFont(f);

g2.drawString("This text is OK : " , 30, 40);

f = new Font("Arail", Font.PLAIN, 11);

g2.setFont(f);

g2.drawString("Page : " + ( i +1 ) + " of " + totalPages + " Text OK", 680, 570);

g2.translate(pf.getImageableX(), pf.getImageableY() + 35);

g2.clip(new Rectangle2D.Double(0,0,pf.getImageableWidth(), pf.getImageableHeight()));

//translate and scale:

switch(method){

case BOOK_WIDTH:

g2.translate(0, -page*pf.getImageableHeight());

break;

case BOOK_HEIGHT:

g2.translate(-page*pf.getImageableWidth(),0);

break;

}

g2.scale(scale, scale);

//finally do the printing:

//disableDoubleBuffering(component[i]);

component[i].paint(g2);

System.out.println("paint calls = " + ++paintcall);

//enableDoubleBuffering(component[i]);

if (paintcall == 2){

return (NO_SUCH_PAGE);

}

return(PAGE_EXISTS);

}

}

}

}

alan_314a at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...
# 4

The answer is simple: use 1.5.0_08 or later.

The cause is that Swing's windows Look and Feel in earlier versions

of 1.5 was using lots of tiny translucent images which were obtained

from some windows resources to emulate the windows 'look'.

Your case (number of resulting print calls) sounds more extreme than

anything I've heard of or seen, but its the basic issue.

In 1.5.0_08 that Swing code was changed to use the window uxtheme APIs

and problem solved : no more translucent images. It is also OK in JDK 6.

philra at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...
# 5

Hi Phil,

thanks for the reply , i have tried your suggestion but got some mixed results.

Using jre1.5.0_09, the text looks a bit better but still not as good 1.42. The number of paint calls is down to 35. I have noticed some random crashes whn trying to print a book of 12 pages or the printing stops after a few pages. A couple of times it printed the whole book.

Here is the error log from 1 of the crashes

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c9010f3, pid=29548, tid=13988

#

# Java VM: Java HotSpot(TM) Client VM (1.5.0_09-b03 mixed mode, sharing)

# Problematic frame:

# C [ntdll.dll+0x10f3]

#

T H R E A D

Current thread (0x00a0bb48): JavaThread "Finalizer" daemon [_thread_in_native, id=13988]

siginfo: ExceptionCode=0xc0000005, writing address 0x056bf014

Registers:

EAX=0x00000000, EBX=0x00000000, ECX=0x02f8f6d8, EDX=0x056bf00c

ESP=0x02f8f6e8, EBP=0x02f8f720, ESI=0x056beff8, EDI=0x056bf00c

EIP=0x7c9010f3, EFLAGS=0x00010246

Top of Stack: (sp=0x02f8f6e8)

0x02f8f6e8:6d0d9469 056bf00c 056beff8 00a0bc08

0x02f8f6f8:6d0d1218 00a701e5 0ad9eda0 00a0bb48

0x02f8f708:00000000 00000000 02f8f6fc 02f8f838

0x02f8f718:6d0f5b2c 00000000 02f8f738 00cac480

0x02f8f728:00a0bc08 02f8f740 06f12780 02f8f740

0x02f8f738:02f8f758 00bf8a4a 06eeb5d8 00c8fd2d

0x02f8f748:06eec628 00a77769 02f8f750 2ab20648

0x02f8f758:02f8f76c 00ace580 06eeb5d8 2b390650

Instructions: (pc=0x7c9010f3)

0x7c9010e3:24 00 00 00 00 90 90 90 90 90 8b 54 24 04 33 c0

0x7c9010f3:ff 4a 08 75 26 89 42 0c f0 ff 4a 04 7d 03 c2 04

Stack: [0x02e90000,0x02f90000), sp=0x02f8f6e8, free space=1021k

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)

C [ntdll.dll+0x10f3]

J java.awt.Font.pDispose()V

J java.awt.Font.finalize()V

v ~RuntimeStub::alignment_frame_return Runtime1 stub

v ~StubRoutines::call_stub

V [jvm.dll+0x86e84]

V [jvm.dll+0xddead]

V [jvm.dll+0x86d55]

V [jvm.dll+0x8c128]

C [java.dll+0x2006]

J java.lang.ref.Finalizer.runFinalizer()V

J java.lang.ref.Finalizer$FinalizerThread.run()V

v ~OSRAdapter

v ~StubRoutines::call_stub

V [jvm.dll+0x86e84]

V [jvm.dll+0xddead]

V [jvm.dll+0x86d55]

V [jvm.dll+0x86ab2]

V [jvm.dll+0xa16b2]

V [jvm.dll+0x10f4ac]

V [jvm.dll+0x10f47a]

C [MSVCRT.dll+0x2a3b0]

C [kernel32.dll+0xb683]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)

J java.awt.Font.pDispose()V

J java.awt.Font.finalize()V

v ~RuntimeStub::alignment_frame_return Runtime1 stub

v ~StubRoutines::call_stub

J java.lang.ref.Finalizer.invokeFinalizeMethod(Ljava/lang/Object;)V

J java.lang.ref.Finalizer.runFinalizer()V

J java.lang.ref.Finalizer$FinalizerThread.run()V

v ~OSRAdapter

v ~StubRoutines::call_stub

P R O C E S S

Java Threads: ( => current thread )

0x00357ec0 JavaThread "DestroyJavaVM" [_thread_blocked, id=7316]

0x05519a90 JavaThread "AWT-EventQueue-1" [_thread_in_native, id=30548]

0x03567ce8 JavaThread "TimerQueue" daemon [_thread_blocked, id=10732]

0x0349c4d8 JavaThread "OutputFileMonitor" [_thread_blocked, id=14032]

0x033d8e18 JavaThread "AWT-Shutdown" [_thread_blocked, id=14920]

0x03493028 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=5204]

0x034921b0 JavaThread "AWT-Windows" daemon [_thread_in_native, id=14556]

0x00a12d10 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1248]

0x00a118f8 JavaThread "CompilerThread0" daemon [_thread_blocked, id=9736]

0x00a10c98 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=15052]

=>0x00a0bb48 JavaThread "Finalizer" daemon [_thread_in_native, id=13988]

0x00a0a780 JavaThread "Reference Handler" daemon [_thread_blocked, id=13108]

Other Threads:

0x00a08e28 VMThread [id=14484]

0x00a13f28 WatcherThread [id=11932]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap

def new generationtotal 4416K, used 519K [0x06a70000, 0x06f30000, 0x091d0000)

eden space 3968K,1% used [0x06a70000, 0x06a81c18, 0x06e50000)

from space 448K, 100% used [0x06ec0000, 0x06f30000, 0x06f30000)

tospace 448K,0% used [0x06e50000, 0x06e50000, 0x06ec0000)

tenured generationtotal 58116K, used 34480K [0x091d0000, 0x0ca91000, 0x26a70000)

the space 58116K, 59% used [0x091d0000, 0x0b37c0b8, 0x0b37c200, 0x0ca91000)

compacting perm gen total 8192K, used 6278K [0x26a70000, 0x27270000, 0x2aa70000)

the space 8192K, 76% used [0x26a70000, 0x27091910, 0x27091a00, 0x27270000)

ro space 8192K, 63% used [0x2aa70000, 0x2af7d860, 0x2af7da00, 0x2b270000)

rw space 12288K, 46% used [0x2b270000, 0x2b810728, 0x2b810800, 0x2be70000)

Dynamic libraries:

0x00400000 - 0x0040d000 C:\mb\Jre\jre_1.5.0-09\bin\javaw.exe

0x7c900000 - 0x7c9b0000 C:\WINDOWS\system32\ntdll.dll

0x7c800000 - 0x7c8f4000 C:\WINDOWS\system32\kernel32.dll

0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.dll

0x77e70000 - 0x77f01000 C:\WINDOWS\system32\RPCRT4.dll

0x77d40000 - 0x77dd0000 C:\WINDOWS\system32\USER32.dll

0x77f10000 - 0x77f57000 C:\WINDOWS\system32\GDI32.dll

0x77c10000 - 0x77c68000 C:\WINDOWS\system32\MSVCRT.dll

0x6d6c0000 - 0x6d85b000 C:\mb\Jre\jre_1.5.0-09\bin\client\jvm.dll

0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll

0x6d280000 - 0x6d288000 C:\mb\Jre\jre_1.5.0-09\bin\hpi.dll

0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL

0x6d690000 - 0x6d69c000 C:\mb\Jre\jre_1.5.0-09\bin\verify.dll

0x6d300000 - 0x6d31d000 C:\mb\Jre\jre_1.5.0-09\bin\java.dll

0x6d6b0000 - 0x6d6bf000 C:\mb\Jre\jre_1.5.0-09\bin\zip.dll

0x6d000000 - 0x6d169000 C:\mb\Jre\jre_1.5.0-09\bin\awt.dll

0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV

0x76390000 - 0x763ad000 C:\WINDOWS\system32\IMM32.dll

0x774e0000 - 0x7761d000 C:\WINDOWS\system32\ole32.dll

0x5ad70000 - 0x5ada8000 C:\WINDOWS\system32\uxtheme.dll

0x03790000 - 0x038ff000 C:\WINDOWS\system32\nview.dll

0x77f60000 - 0x77fd6000 C:\WINDOWS\system32\SHLWAPI.dll

0x7c9c0000 - 0x7d1d5000 C:\WINDOWS\system32\SHELL32.dll

0x77120000 - 0x771ac000 C:\WINDOWS\system32\OLEAUT32.dll

0x5d090000 - 0x5d12a000 C:\WINDOWS\system32\COMCTL32.dll

0x77c00000 - 0x77c08000 C:\WINDOWS\system32\VERSION.dll

0x773d0000 - 0x774d3000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll

0x77690000 - 0x776b1000 C:\WINDOWS\system32\NTMARTA.DLL

0x76f60000 - 0x76f8c000 C:\WINDOWS\system32\WLDAP32.dll

0x71bf0000 - 0x71c03000 C:\WINDOWS\system32\SAMLIB.dll

0x74720000 - 0x7476b000 C:\WINDOWS\system32\MSCTF.dll

0x6d240000 - 0x6d27f000 C:\mb\Jre\jre_1.5.0-09\bin\fontmanager.dll

0x6d3c0000 - 0x6d3df000 C:\mb\Jre\jre_1.5.0-09\bin\jpeg.dll

0x03d50000 - 0x03d65000 C:\WINDOWS\system32\nvwddi.dll

0x04120000 - 0x048b0000 C:\mb\Ucam801\bin\ucam.dll

0x71ab0000 - 0x71ac7000 C:\WINDOWS\system32\WS2_32.dll

0x71aa0000 - 0x71aa8000 C:\WINDOWS\system32\WS2HELP.dll

0x5b860000 - 0x5b8b4000 C:\WINDOWS\system32\NETAPI32.dll

0x763b0000 - 0x763f9000 C:\WINDOWS\system32\comdlg32.dll

0x03f80000 - 0x03fa5000 C:\WINDOWS\system32\IBFS32.DLL

0x6d4c0000 - 0x6d4d3000 C:\mb\Jre\jre_1.5.0-09\bin\net.dll

0x6d4e0000 - 0x6d4e9000 C:\mb\Jre\jre_1.5.0-09\bin\nio.dll

0x76d60000 - 0x76d79000 C:\WINDOWS\system32\iphlpapi.dll

0x74290000 - 0x74294000 C:\WINDOWS\system32\icmp.Dll

0x71a50000 - 0x71a8f000 C:\WINDOWS\System32\mswsock.dll

0x76f20000 - 0x76f47000 C:\WINDOWS\system32\DNSAPI.dll

0x76fb0000 - 0x76fb8000 C:\WINDOWS\System32\winrnr.dll

0x77fe0000 - 0x77ff1000 C:\WINDOWS\system32\Secur32.dll

0x662b0000 - 0x66308000 C:\WINDOWS\system32\hnetcfg.dll

0x71a90000 - 0x71a98000 C:\WINDOWS\System32\wshtcpip.dll

0x76fc0000 - 0x76fc6000 C:\WINDOWS\system32\rasadhlp.dll

0x77b40000 - 0x77b62000 C:\WINDOWS\system32\Apphelp.dll

0x71b20000 - 0x71b32000 C:\WINDOWS\system32\MPR.dll

0x75f60000 - 0x75f67000 C:\WINDOWS\System32\drprov.dll

0x71c10000 - 0x71c1e000 C:\WINDOWS\System32\ntlanman.dll

0x71cd0000 - 0x71ce7000 C:\WINDOWS\System32\NETUI0.dll

0x71c90000 - 0x71cd0000 C:\WINDOWS\System32\NETUI1.dll

0x71c80000 - 0x71c87000 C:\WINDOWS\System32\NETRAP.dll

0x75f70000 - 0x75f79000 C:\WINDOWS\System32\davclnt.dll

0x77920000 - 0x77a13000 C:\WINDOWS\system32\SETUPAPI.dll

0x04c30000 - 0x04cb5000 C:\Program Files\Nokia\Nokia PC Suite 6\PhoneBrowser.dll

0x04cc0000 - 0x04d4c000 C:\Program Files\Nokia\Nokia PC Suite 6\PCSCM.dll

0x04d50000 - 0x04d8f000 C:\WINDOWS\system32\ConnAPI.DLL

0x7c3a0000 - 0x7c41b000 C:\WINDOWS\system32\MSVCP71.dll

0x7c340000 - 0x7c396000 C:\WINDOWS\system32\MSVCR71.dll

0x76380000 - 0x76385000 C:\WINDOWS\system32\MSIMG32.dll

0x5edd0000 - 0x5ede7000 C:\WINDOWS\system32\OLEPRO32.DLL

0x77260000 - 0x77300000 C:\WINDOWS\system32\urlmon.dll

0x771b0000 - 0x77259000 C:\WINDOWS\system32\WININET.dll

0x77a80000 - 0x77b14000 C:\WINDOWS\system32\CRYPT32.dll

0x77b20000 - 0x77b32000 C:\WINDOWS\system32\MSASN1.dll

0x04ec0000 - 0x04eca000 C:\Program Files\Nokia\Nokia PC Suite 6\Lang\PhoneBrowser_eng.nlr

0x04f50000 - 0x04fdb000 C:\Program Files\Nokia\Nokia PC Suite 6\Resource\PhoneBrowser_Nokia.ngr

0x76fd0000 - 0x7704f000 C:\WINDOWS\system32\CLBCATQ.DLL

0x77050000 - 0x77115000 C:\WINDOWS\system32\COMRes.dll

0x04fe0000 - 0x05059000 C:\WINDOWS\system32\Audiodev.dll

0x05060000 - 0x052a4000 C:\WINDOWS\system32\WMVCore.DLL

0x04ed0000 - 0x04f0b000 C:\WINDOWS\system32\WMASF.DLL

0x76c30000 - 0x76c5e000 C:\WINDOWS\system32\WINTRUST.dll

0x76c90000 - 0x76cb8000 C:\WINDOWS\system32\IMAGEHLP.dll

0x76980000 - 0x76988000 C:\WINDOWS\system32\LINKINFO.dll

0x76990000 - 0x769b5000 C:\WINDOWS\system32\ntshrui.dll

0x76b20000 - 0x76b31000 C:\WINDOWS\system32\ATL.DLL

0x769c0000 - 0x76a73000 C:\WINDOWS\system32\USERENV.dll

0x76400000 - 0x765a6000 C:\WINDOWS\system32\NETSHELL.dll

0x76e80000 - 0x76e8e000 C:\WINDOWS\system32\rtutils.dll

0x76c00000 - 0x76c2e000 C:\WINDOWS\system32\credui.dll

0x77a20000 - 0x77a74000 C:\WINDOWS\System32\cscui.dll

0x76600000 - 0x7661d000 C:\WINDOWS\System32\CSCDLL.dll

0x058d0000 - 0x05913000 C:\Program Files\Microsoft Private Folder 1.0\ShellExt.dll

0x05930000 - 0x05953000 C:\WINDOWS\system32\PFLib.dll

0x4ffe0000 - 0x4ffe8000 C:\WINDOWS\system32\FLTLIB.DLL

0x05990000 - 0x05c55000 C:\WINDOWS\system32\xpsp2res.dll

0x767a0000 - 0x767d6000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\UNIDRVUI.DLL

0x767e0000 - 0x76825000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\UNIDRV.DLL

0x2d4e0000 - 0x2d6d9000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\HPBF222E.DLL

0x6e680000 - 0x6e6bb000 C:\WINDOWS\system32\COMPSTUI.dll

0x2dae0000 - 0x2dc64000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\HPBF222G.DLL

0x6c600000 - 0x6c84b000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634U.DLL

0x68f00000 - 0x68f33000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634C.DLL

0x6c500000 - 0x6c519000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634L.DLL

0x68500000 - 0x6853a000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634X.DLL

0x6e000000 - 0x6e006000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634ZU.DLL

0x6e030000 - 0x6e048000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634WU.DLL

0x04a70000 - 0x04aa4000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634K.DLL

0x04ab0000 - 0x04ad1000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634P.DLL

0x03d40000 - 0x03d4e000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634J.DLL

0x68d00000 - 0x68d09000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634ZK.DLL

0x04ae0000 - 0x04ae5000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\NRG634WK.DLL

0x04af0000 - 0x04af7000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\hpblff0.dll

0x2ed70000 - 0x2ede3000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBLFF7.dll

0x04b00000 - 0x04b11000 C:\WINDOWS\system32\MSVCIRT.dll

0x2edf0000 - 0x2eef1000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBLFF3.DLL

0x06a30000 - 0x06a4c000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBLFF1.DLL

0x6a900000 - 0x6a9c0000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\win2pdfi.dll

0x2ef00000 - 0x2ef62000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\win2pdf.dll

0x2ef70000 - 0x2ef99000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\FXSUI.DLL

0x71550000 - 0x7156f000 C:\WINDOWS\system32\ACLUI.dll

0x5a980000 - 0x5a9f2000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\FXSAPI.dll

0x68eb0000 - 0x68eb6000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\FXSRES.dll

0x5a8b0000 - 0x5a8e2000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\FXSWZRD.dll

0x76080000 - 0x760e5000 C:\WINDOWS\system32\MSVCP60.dll

0x76eb0000 - 0x76edf000 C:\WINDOWS\system32\TAPI32.dll

0x68d30000 - 0x68d94000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\FXSTIFF.dll

0x68f40000 - 0x68f4a000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\3\FXSDRV.DLL

0x6d1c0000 - 0x6d1e3000 C:\mb\Jre\jre_1.5.0-09\bin\dcpr.dll

VM Arguments:

jvm_args: -Dsun.java2d.d3d=false -Dsun.java2d.noddraw=true -Dswing.useSystemFontSettings=false -Xverify:none -Xss256k -Xmx512m

java_command: Ucam -unit=mil

Launcher Type: SUN_STANDARD

Environment Variables:

JAVA_HOME=C:\j2sdk1.4.2_10\bin

PATH=C:\mb\Ucam801\autofixture\bin;C:\mb\Ucam801\autofixture\Perl\bin;C:\mb\Ucam801\autofixture\Tcl\bin;C:\mb\Ucam801\flexlm;C:\mb\Ucam801\bin;C:\PXPerl\parrot\bin;C:\PXPerl\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\j2sdk1.4.2_10\bin;"\";C:\Program Files\Support Tools;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\bin;C:\usr\local\bin;C:\PROGRA~1\VISION;C:\PROGRA~1\VISION\System;C:\PROGRA~1\COMMON~1\VISION;"C:\Program Files\IGC\DWG Viewer";C:\Program Files\ActiveState Komodo 3.0\

USERNAME=alan.coombes

DISPLAY=:0.0

OS=Windows_NT

PROCESSOR_IDENTIFIER=x86 Family 6 Model 13 Stepping 8, GenuineIntel

S Y S T E M

OS: Windows XP Build 2600 Service Pack 2

CPU:total 1 (cores per cpu 1, threads per core 1) family 6 model 13 stepping 8, cmov, cx8, fxsr, mmx, sse, sse2

Memory: 4k page, physical 1047960k(259748k free), swap 2518916k(1618112k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_09-b03) for windows-x86, built on Oct 12 2006 01:20:10 by "java_re" with MS VC++ 6.0

Using jre1.6.0 the text looks much better and 35 paint calls for the same page. The text loks a bit stange as there very little space between some of the characters. Im stuck with using 1.5 for the moment.

alan_314a at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...
# 6

I wasn't directly addressing the text issue - just the many calls issue.

There are still > 2 calls per page so there is still some translucency here.

This then comes down to the way that we handle printing translucent images,

and it had some bugs. These were fixed as part of resolving :

6301927 : Java 1.4.2 does not print labels of buttons when using Windows XP Style

This as you can see is related to your case and could in some cases also affect

1.4.2 (ie its not that printing changed in 1.5 relative to 1.4.2 - its that Swing changed

and you were more likely to hit this).

That is fixed in JDk 6 and was supposed to be backported to 5u10.

It didn't make it. I am not sure it will make 5u11 either. Probably not.

But I'll see what I can do.

Some general advice here though.

You are calling Component.paint() in the print method.

Instead call Component.print() or Component.printAll()

That is required to turn off Swing double-buffering.

It won't help until 6301927 is fixed but at least you'll be ready

The crash in finalization could be a few things. It could be an AWT bug :

pDispose is used by AWT when using GDI fonts on windows heavyweights.

Printing currently uses that code to print logical fonts (eg Dialog)

What is noteworthy here is that you misspell Arial as Arail.

This could make a difference Arial (if spelled correctly), should not

need to do anything in pDispose() as it doesn't trigger the creation of

the AWT font peer.

Your Swing.useSystemFontSettings=false also (I think) means you

are more likely to use logical fonts in which pDispose() needs to do something

As I said the finalization crash could be a few things. In some extreme cases

so much finalization happens that garbage collection is starved.

I am not sure how starved you are here. Free space looks reasonable to me,

and I can't see that you are creating lots of fonts so its a bit muddy

Anyway, this is addressed (to a large degree) by the fix for 6186524.

There will be far fewer fonts used and finalization is much less of an issue.

That fix *IS* in 51u0 (available 'soon'). Hopefully using that JDK and fewer

logical fonts you'll be fine there.

philra at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...
# 7

I made the following changes -

component.printAll();

and

changed Arail to Arial ( a typo from a few years ago)

and

-Dswing.useSystemFontSettings=true

This seemed to work on my PC ( 2GHZ Pentium M) but when I tried it on another PC ( 3.4GHZ Pentium 4 with HT )

the old problems started again ( shut down or printing stops after a few pages).

Both PC's are using 5u9.

On reading some of the bug reports for related issues, I tried

-Dsun.java2d.print.shapetext=true

and this resolved the problems on the other PC. Spool files where alot larger and printing slower but at least the job got done.

Unless there is anything else to try I suppose I will have to wait for the update to be released. Any ideas on timescales?

Cheers

alan_314a at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...
# 8
I'm still getting this crash while printing on 1.5.0_u10 unfortunately.I have found this bug reference below and am awaiting the 1.5.0 update where it is fixed. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6480378
BruceJGarnera at 2007-7-15 3:56:27 > top of Java-index,Desktop,Core GUI APIs...