画图而而已!
见代码;
package bdzhidao;
import javaawt;
import javaxswing;
import javaawtevent;
public class ChangePic extends JFrame {
private static ImageIcon img0Icon=new ImageIcon("image/Tu0jpg");
private static Image img0=img0IcongetImage();
private static ImageIcon img1Icon=new ImageIcon("image/无奈gif");
private static Image img1=img1IcongetImage();
public ChangePic(){
final ChangePicPanel jp=new ChangePicPanel();
JButton jbt=new JButton("换图");
jpadd(jbt);
thisadd(jp);
jbtaddActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Graphics G=jpgetGraphics();
GdrawImage(img1,0,0,jp);
}
});
}
static class ChangePicPanel extends JPanel{
protected void paintComponent(Graphics g){
superpaintComponent(g);
gdrawImage(img0,0,0,this);
}
}
public static void main(String[] args){
JFrame frame=new ChangePic();
framesetTitle("换图");
framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
framesetResizable(false);
framesetLocationRelativeTo(null);
framesetSize(320,240);
framesetVisible(true);
}
}
<script language="javascript" src=">欢迎分享,转载请注明来源:内存溢出
评论列表(0条)