Graphics g怎么又画不出来了,求解释
import javax.swing.*;import java.awt.*;public class Gck extends JPanel { private JFrame frame; private JPanel panel; private JButton start,out; public Gck(){ panel = new JPanel(null); start=new JButton("start"); out=new JButton("out"); start.setLocation(10, 10); start.setSize(70, 30); out.setLocation(90, 10); out.setSize(70, 30); frame=new JFrame("**"); panel.add(start); panel.add(out); frame.add(panel); frame.setSize(410, 550); frame.setLocation(200, 200); frame.setVisible(true); } public void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(Color.BLACK); g.fillRect(10, 50, 370,450); } public static void main(String[] args) { new Gck(); }}package com.kay;import java.awt.Color;import java.awt.EventQueue;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.geom.Rectangle2D;import java.awt.geom.Rectangle2D.Double;import javax.swing.JComponent;import javax.swing.JFrame;import javax.swing.JPanel;public class Gck { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub EventQueue.invokeLater(new Runnable(){ public void run(){ DrawFrame1 fram=new DrawFrame1(); fram.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fram.setVisible(true); } }); }}class DrawFrame1 extends JFrame{ public DrawFrame1(){ setTitle("Gck"); setSize(D_W,D_H); DrawPanel dp=new DrawPanel(); add(dp); } public static final int D_W=400; public static final int D_H=400;}class DrawPanel extends JPanel{ public void paintComponent(Graphics g){ Graphics2D g2=(Graphics2D) g; double leftx=100; double topy=100; double width=200; double height=150; Rectangle2D rect=new Rectangle2D.Double(leftx,topy,width,height); g2.draw(rect); }}