JDK-4238883 : Error in Component.printAll( Graphics g );
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-05-17
  • Updated: 1999-07-27
  • Resolved: 1999-07-27
Related Reports
Duplicate :  
Description

Name: skT88420			Date: 05/17/99


In jdk\1.2.1\src\java\awt\Component.java
method: printAll( Graphics g );
line number: 1963
Here is the method:

    public void printAll(Graphics g) {
	ComponentPeer peer = this.peer;
	if (visible && (peer != null)) {
	    validate();
	    Graphics cg = g.create(0, 0, width, height);
	    cg.setFont(getFont());
	    try {
	        if (peer instanceof java.awt.peer.LightweightPeer) {
		         lightweightPrint(g);
		      } else {
		         peer.print(g);
		      }
	    } finally {
	        cg.dispose();
	    }
	}
    }

The line number reads as follows:
          lightweightPrint(g);
I believe this should be:
          lightweightPrint( cg );
My question is, why is the following code being declared and
setup if it is not used anywhere?
	    Graphics cg = g.create(0, 0, width, height);
	    cg.setFont(getFont());
Please let me know if I am wrong.
(Review ID: 83161) 
======================================================================

Comments
WORK AROUND Name: skT88420 Date: 05/17/99 Whoever wants to print should copy the method printAll() and lieghtweightPrint() into their java file and change the line: lightWeightPrint(g) to: lightWeightPrint(cg); ========================================================= The probable cause may be the implementation of the suggested fix in bug ID: 4155884. Suggested fix: ------- Component.java ------- *** /tmp/d0MI9vE Thu Jul 9 11:33:36 1998 --- Component.java Thu Jul 9 11:30:37 1998 *************** *** 1401,1407 **** Graphics cg = g.create(0, 0, width, height); cg.setFont(getFont()); try { ! peer.print(cg); <---------------- Used to use cg } finally { cg.dispose(); } --- 1401,1412 ---- Graphics cg = g.create(0, 0, width, height); cg.setFont(getFont()); try { ! if (peer instanceof java.awt.peer.LightweightPeer) { ! lightweightPrint(g); <---------------- Suggested fix using g ! } ! else { ! peer.print(g); ! } } finally { cg.dispose(); } ======================================================================
11-06-2004