Greetings All,

I'm attempting to test out Classpath's AWT support, specifically in
the context of component image capture capability necessary to support
the Eclipse Visual Editor project.  Classpath's Component.printAll()
method is returning a badly garbled image (with Classpath 0.10 running
via jamvm).  Attached is a simple testcase of this issue.  Any help
resolving this issue would be appreciated.

Thanks,
 - Jeff Myers
import java.awt.Button;
import java.awt.Canvas;
import java.awt.Checkbox;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Label;
import java.awt.Panel;
import java.awt.ScrollPane;

public class AWTPrintAllTest {

	private Frame displayFrame = null;  
	private Label label = null;
	private Button button = null;
	private Frame captureFrame = null; 
	private Panel panel = null;
	private Checkbox checkbox = null;
	private Button button1 = null;
	private ScrollPane scrollPane = null;
	private Canvas canvas = null;
	private Button button2 = null;
	
	public Image componentImage = null;
	
	private class ImageCanvas extends Canvas {
		public void paint(Graphics g) {
			super.paint(g);
			if (componentImage != null) {
				this.setSize(componentImage.getWidth(this), componentImage.getHeight(this));
				g.drawImage(componentImage, 0, 0, this);
			}
		}
	}
	
	public static void main(String[] args) {
     	AWTPrintAllTest apat = new AWTPrintAllTest();
     	apat.getDisplayFrame().setVisible(true);
     	apat.getCaptureFrame().setVisible(true);
	}
	
	private Frame getDisplayFrame() {
		if (displayFrame == null) {
			displayFrame = new Frame();
			label = new Label();
			displayFrame.setLayout(null);
			displayFrame.setSize(148, 98);
			displayFrame.setTitle("Frame");
			displayFrame.setLocation(200, 200);
			label.setBounds(16, 32, 47, 41);
			label.setText("Label");
			displayFrame.add(label, null);
			button = new Button();
			button.setBounds(74, 37, 54, 39);
			button.setLabel("Button");
			displayFrame.add(button, null);
		}
		return displayFrame;
	}

	private Frame getCaptureFrame() {
		if (captureFrame == null) {
			captureFrame = new Frame();
			captureFrame.setSize(246, 181);
			captureFrame.setTitle("Print All Test");
			panel = new Panel();
			checkbox = new Checkbox();
			checkbox.setLabel("Off Screen");
			checkbox.addItemListener(new java.awt.event.ItemListener() { 
				public void itemStateChanged(java.awt.event.ItemEvent e) {    
					if (checkbox.getState()) {
						getDisplayFrame().setLocation(10000,10000);
					} else {
						getDisplayFrame().setLocation(200,200);
					}
				}
			});
			panel.add(checkbox, null);
			button1 = new Button();
			button1.setLabel("Grab");
			button1.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {
					Component component = getDisplayFrame();
					componentImage = component.createImage(component.getWidth(), component.getHeight());
					Graphics graphics = componentImage.getGraphics();
					component.printAll(graphics);
					canvas.repaint();
				}
			});
			panel.add(button1, null);
			button2 = new Button();
			button2.setLabel("Quit");
			button2.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					System.exit(0);
				}
			});
			panel.add(button2, null);
			captureFrame.add(panel, java.awt.BorderLayout.SOUTH);
			scrollPane = new ScrollPane();
			canvas = new ImageCanvas();
			scrollPane.add(canvas, null);
			captureFrame.add(scrollPane, java.awt.BorderLayout.CENTER);
			captureFrame.addWindowListener(new java.awt.event.WindowAdapter() { 
				public void windowClosing(java.awt.event.WindowEvent e) {    
					System.exit(0);
				}
			});
		}
		return captureFrame;
	}
}
_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to