如何将一个3D画布加载到一个JPANEL里面
class SanWeiTuXingGUI extends JPanel implements ActionListener
 {
protected Canvas3D canvas;
JButton back;
public SanWeiTuXingGUI()
{
back=new JButton("返回");
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
        template.setDoubleBuffer(template.REQUIRED);
        GraphicsEnvironment env =GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice dev = env.getDefaultScreenDevice();
        canvas = new Canvas3D(dev.getBestConfiguration(template));
        canvas.setStereoEnable(false);
        canvas.setDoubleBufferEnable(true);
        canvas.setVisible(true);
        this.setLayout(new BorderLayout());
        this.add(canvas,"Center");
        this.add(back,"South");
        
}
public void actionPerformed(ActionEvent e)
{
layout.show(pCenter,"WELCOME MODE");
}

  }
}
这么做为什么画布显示不出来??????

解决方案 »

  1.   

    class bb
    {
    public static void main(String [] args)
    {
            
             int x=-7,y=9;
             int sum = getArea(x,y);
             System.out.println(sum);
            
             }
            static int getArea(int x,int y)
            {
             if(x<0 || y<0)
             {
             System.out.println("有负数!");
                            
             }
             int z;
             z=x*y;
             return z;
            }
    }
    这样就行啦!!