Home pageFind It!Contact PJAPJA documentation

PJA

 PJA Toolkit forum

This forum is dedicated to PJA Toolkit.
You may read freely the messages it contents. If you want to write a message or answer to a subject, subscribe to it first.

Subjects Recent messages Login Subscribe

Messages of subject Problem drawing all of JPanel's children

squishymonkey

Location : Tempe, AZ USA
Member since : Mar 22, 2004
Messages : 1
 Mar 22, 2004 at 11:17 PM
Hello,

I am attempting to encode charts into images to send back to a thin client. Up until now, everything has worked wonderfully. Now I have need to draw two charts, one above the other. Since I didn't want to have to run the same data twice, my solution was to add both charts to a JPanel and draw the JPanel into an image. When my image comes back, only the first chart added is drawn. A very simple example using JPanels with different background colors is below:

<CODE>
int imgWidth = 750;
int imgHeight = 480;

JPanel panel = new JPanel(new GridLayout(2,1));
panel.setSize(imgWidth, imgHeight);

JPanel upperPanel = new Panel();
upperPanel.setBackground(Color.BLUE);
upperPanel.setSize(imgWidth, imgHeight/2);

JPanel lowerPanel = new JPanel();
lowerPanel.setBackground(Color.YELLOW);
lowerPanel.setSize(imgWidth, imgHeight/2);

panel.add(upperPanel);
panel.add(lowerPanel);

BufferedImage image = new java.awt.image.BufferedImage(imgWidth,imgHeight, PJABufferedImage.TYPE_BYTE_INDEXED);
Graphics2D g=(Graphics2D)image.getGraphics();


panel.addNotify();
panel.paint(g);

</CODE>

The resulting image that comes back is the correct size. The blue upper panel (the first added) is the correct size and in the correct position, however, the yellow lower panel is not drawn, instead I see the red background of the parent panel.

Am I missing something? Is there another step I need to take in order for this second child to be drawn? Any idea why this is happening?

Thanks in advance for your help.

D~


Home pageFind It!ContactTop

© Copyrights 1997-2023 eTeks - All rights reserved

PJAPJA documentation