jave中窗口大小改变时(如最大化,拉伸窗口时),窗口里的图像为什么不显示(重绘)?
importjava.awt.Graphics;importjava.awt.Image;importjava.awt.event.WindowAdapter;impor...
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class DrawImageINFrame extends JFrame {
public void paint(Graphics g){
Image ima=new ImageIcon("image/a2.jpg").getImage();
g.drawImage(ima, 0, 0, 800, 600, this);
}
public static void main(String[] args) {
DrawImageINFrame d=new DrawImageINFrame();
d.setSize(600, 600);
d.setDefaultCloseOperation(EXIT_ON_CLOSE);
d.setVisible(true);
}
} 展开
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class DrawImageINFrame extends JFrame {
public void paint(Graphics g){
Image ima=new ImageIcon("image/a2.jpg").getImage();
g.drawImage(ima, 0, 0, 800, 600, this);
}
public static void main(String[] args) {
DrawImageINFrame d=new DrawImageINFrame();
d.setSize(600, 600);
d.setDefaultCloseOperation(EXIT_ON_CLOSE);
d.setVisible(true);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询