public class YWindows extends JLabel
{
    private Graphics g;
    
    private JFrame frame;
    
    private JScrollPane spanel;
    
    public YWindows ()
    {
       frame = new JFrame("Graphics");
       
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
       spanel = new JScrollPane(this);
       
       frame.setContentPane(spanel);
       
       
//       frame.setSize(1300, 1300);
       
       frame.pack();
       
       frame.setVisible(true);
       
       this.setLayout(null);
       this.paint(g);
    }
    
    @Override
    public void paint(Graphics g)
    {
        g.setColor(Color.CYAN);
        g.fillRect(10, 10, 196, 152);
        
        g.setColor(Color.red);
        g.fillRect(206, 10, 100, 100);
        
        g.setColor(Color.PINK);
        g.fillRect(10, 152, 443, 443);
        
        g.setColor(Color.CYAN);
        g.fillRect(275, 595, 100, 155);//L3
        
        
        g.setColor(Color.PINK);
        g.fillRect(10, 595, 275, 155);
        
        g.setColor(Color.PINK);
        g.fillRect(10, 750, 375, 342);
        
    }
    
    
    public static void main(String[] args)
    {
        new YWindows();
    }
    
}
这是我写的代码,我的意思是直接在画布上绘图,然后加入到面板上。而不是载入图片。
请教一下。谢谢……