完全可以public class RTWindow extends JPanel{

private Image image;

public RTWindow(){
this.setVisible(true);
this.setPreferredSize(new Dimension(120,25));
}

public void paint(Graphics g) {
   super.paint(g);
   g.setXORMode(this.getBackground());
   Graphics2D g2=(Graphics2D)g;
   Stroke stroke=new BasicStroke(0.1f);
   Stroke stroke2=new BasicStroke(2.0f);
  g2.setStroke(stroke);
  g2.setColor(Color.white);
   g2.drawRect(10,10,100,5);
   g2.setColor(Color.red);
   g2.fillRect(10,10,30,5);
   g2.setColor(Color.green);
   g2.fillRect(40,10,70,5);
   g2.setStroke(stroke2);
   g2.setColor(Color.black);
   g2.drawLine(50,10,50,15);  /**@todo Override this java.awt.Component method*/
  g.drawImage(image,30,30,this);
} void jButton1_actionPerformed(ActionEvent e) {
  Graphics g=this.getGraphics();
  image.flush();
  g.drawImage(image,30,30,this);
}
  }