如果你真想写,你一定可以写出来
这又不是多难

解决方案 »

  1.   

    //Oval.java
    import java.awt.*;
    import java.awt.event.*;import javax.swing.*;public class Oval extends JFrame implements ActionListener{

    Color c=Color.red;

    public Oval(){
    setSize(400,300);

    this.getContentPane().setLayout(new FlowLayout());

    JButton b=new JButton("选色");

    this.getContentPane().add(b);

    b.addActionListener(this);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setVisible(true);
    }

    public static void main(String[] args){
    new Oval();
    }

    public void paint(Graphics g){
    super.paint(g);
    g.setColor(c);
    g.fillOval(50,80,300,200);
    } public void actionPerformed(ActionEvent e){
    JColorChooser jcc=new JColorChooser(c);

    Color sc=jcc.showDialog(this,"",c);

    if(sc!=null){
    c=sc;
    }

    repaint();
    }
    }