bimg是声明成BufferedImage么,给出完整代码

解决方案 »

  1.   

    对阿!!
    package FlowApplication;import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.lang.Math;
    import java.awt.geom.*;
    public class SimpleFlowBuilder implements FlowBuilder 
    {
    private JPanel FlowPanel=null;
    private Graphics graph=null;
    private BufferedImage bimg;
    private Graphics2D g2=null;
    public void buildFlow(Flow newFlow) {
    System.out.println("w12");
    FlowPanel=new JPanel();
    System.out.println("w12");
    graph=FlowPanel.getGraphics();
    System.out.println("w3");
    bimg = (BufferedImage) FlowPanel.createImage(newFlow.Width,newFlow.Height);
    if(bimg==null){
    System.out.println("w433");
    }
    else{
    System.out.println("w45");
    }
    g2=bimg.createGraphics();
    System.out.println("w5");
    // TODO: Add your code here
    }
    }
    相关的代码就这么多阿!!
      

  2.   

    还是自己回答吧!!经过一个多小时的摸索发现,如果jpanel对象不被加到applet.contentpane或者其它类似的对象上时,这就会一直为空阿!!!