代码是这样的:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.image.*;
public class SwingConsole extends JFrame{
public static void run(JFrame j,String name,int width,int height){
j.setTitle(name);
j.setSize(width,height);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setLocation(200,200);
j.setVisible(true);
}
}
class test extends JFrame{
public test(){
addWindowListener(new WindowAdapter(){
void windowActived(WindowEvent e){
repaint();
}
});
}
public void paint(Graphics g){
super.paint(g);
Graphics2D g2d = (Graphics2D)g;
g2d.setPaint(new GradientPaint(50,50,Color.RED,120,50,Color.GREEN,true));
g2d.fill(new Ellipse2D.Double(50,50,100,130));
g2d.setPaint(Color.red);
g2d.setStroke(new BasicStroke(20.0f));
g2d.draw( new Rectangle2D.Double(180,50,140,100));
}
public static void main(String[] argv)
{
SwingConsole.run(new test(),"come on!",400,400);
}
}
这是代码,运行没有问题,但是在使用Tab+Alt切换进程的时候图像就不能重画了,
请问该怎么做才可以使的再切换回来是能够重画呢!谢谢了