🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9536

Why does RepaintManager.getOffscreenBuffer return a null when I pass it a JPanel?

#9536
From: John Hines
Date: Thu, 09 Mar 2000 00:00
84 lines
4074 bytes
This is a modification of an earlier post now that I understand the problem
a little better.

In JDK 1.2.2, I am trying to convert an applet that displays a picture in an
HTML page to a servlet that downloads the picture to the HTML page.  In my
inherited code, the picture is built by placing a bunch of gifs in a
JScrollPane that is added to an instance of a subclass of JPanel.

The code shown below (which uses a brute force created Image) works fine.
At least, it shows the expected image.  And, the size of boundary appears to
be about the right size.  Finally, when I call the program with different
arguments for the proces, the values of Dimension.width and Dimension.height
change in reasonable ways.

However, when I try to get an image from my code using the call

  img = manager.getOffscreenBuffer(diagramManager, dim.width , dim.height );

img is null.  So, nothing works.

I'm sure I'm doing something stupid.  But, what?  I've tried to do repaints
and ... on the panel but nothing I have done has changed the output of
getOffscreenBuffer!  It's always null!

John Hines


    RepaintManager manager = RepaintManager.currentManager(null);
    if (manager == null)
          throw new Exception("null manager in createProcessDiagram in
ProcessDiagramViewerServlet");
    manager.setDoubleBufferingEnabled(true);
    DiagramManager diagramManager = null ;   file://Derived from JPanel
    BufferedImage bufferedImage = null ;
    if (tempProcessList != null) {
      theProcess = (Enactable)tempProcessList.elementAt(0);
    try {
        theProcess.initContents(theSession);     file://build a picture of
the contents

//--------------------------------------------------------------------------
-----------
         // diagram manager is non-null here!
         diagramManager = new DiagramManager(theProcess, this);  //create
image
         // I tried doing paint and repaint and ..., none of which made a
difference

//--------------------------------------------------------------------------
-----------
         Dimension dim = diagramManager.getPreferredSize();

         Image img =getImage(getImageUrl( "process.gif"));

//--------------------------------------------------------------------------
------------
         //the next line always returns a null even though dim.width and
dim.height are not null
         //img = manager.getOffscreenBuffer(diagramManager, dim.width ,
dim.height );
         //the previous line always returns a null even though dim.width and
dim.height are not null

//--------------------------------------------------------------------------
-------------
         if (img == null)
           throw new Exception("null image in createProcessDiagram in
ProcessDiagramViewerServlet");
         bufferedImage = new BufferedImage(dim.width, dim.height,
BufferedImage.TYPE_INT_RGB);
         Graphics bufferedGraphics = bufferedImage.getGraphics();
         bufferedGraphics.drawImage(img, 0, 0, null) ;
       }
      catch (WFException e) {
        System.out.println("WFException: initContents on non-process");
         throw new ServletException("Unable to create image in
createProcessImage");
      }
     catch (Exception e) {
        System.out.println("Exception: " + e);
         throw new ServletException("Unable to create image in
createProcessImage");
    }
  }
Technical Details
Message-ID: <67Vx4.28285$MD3.40895@dfw-read.news.verio.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,304177b1be2b1a85,start
X-Google-Attributes: gid111d45,public
From: "John Hines" <jrhines@onramp.net>
Subject: Why does RepaintManager.getOffscreenBuffer return a null when I pass it a JPanel?
Date: 2000/03/09
Message-ID: <67Vx4.28285$MD3.40895@dfw-read.news.verio.net>
X-Deja-AN: 595343683
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Complaints-To: abuse@verio.net
X-Trace: dfw-read.news.verio.net 952639042 204.0.61.159 (Thu, 09 Mar 2000 21:57:22 GMT)
Organization: Verio
NNTP-Posting-Date: Thu, 09 Mar 2000 21:57:22 GMT
Newsgroups: borland.public.jbuilder.java.swing