Finish the effect:
1 Packagecom.neuedu.test;2 3 ImportJava.awt.Frame;4 ImportJava.awt.Graphics;5 ImportJava.awt.event.WindowAdapter;6 Importjava.awt.event.WindowEvent;7 8 ImportCom.neuedu.utill.GameUtill;9 Ten Public classTaiqiuextendsFrame { One Public voidLoadFrame () { Asetlocation (100, 100); -SetSize (800,600); -Settitle ("Billiards"); theSetresizable (false); -SetVisible (true); -Addwindowlistener (NewWindowadapter () { - + @Override - Public voidwindowclosing (windowevent e) { + //TODO auto-generated Method Stub ASystem.exit (0); at } - - }); - } - @Override - Public voidPaint (Graphics g) { in //TODO auto-generated Method Stub -G.drawimage (Gameutill.getimage ("Com/neuedu/img/zhuomian.png"), 10, 50,NULL); toG.drawimage (Gameutill.getimage ("Com/neuedu/img/0.png"), 200,200,20,20,NULL); +G.drawimage (Gameutill.getimage ("Com/neuedu/img/1.png"), 250,200,20,20,NULL); -G.drawimage (Gameutill.getimage ("Com/neuedu/img/2.png"), 200,250,20,20,NULL); theG.drawimage (Gameutill.getimage ("Com/neuedu/img/3.png"), 300,350,20,20,NULL); *G.drawimage (Gameutill.getimage ("Com/neuedu/img/4.png"), 400,180,20,20,NULL); $G.drawimage (Gameutill.getimage ("Com/neuedu/img/5.png"), 500,200,20,20,NULL);Panax NotoginsengG.drawimage (Gameutill.getimage ("Com/neuedu/img/6.png"), 650,200,20,20,NULL); -G.drawimage (Gameutill.getimage ("Com/neuedu/img/7.png"), 480,200,20,20,NULL); theG.drawimage (Gameutill.getimage ("Com/neuedu/img/8.png"), 580,300,20,20,NULL); +G.drawimage (Gameutill.getimage ("Com/neuedu/img/9.png"), 360,300,20,20,NULL); AG.drawimage (Gameutill.getimage ("Com/neuedu/img/10.png"), 550,350,20,20,NULL); theG.drawimage (Gameutill.getimage ("Com/neuedu/img/11.png"), 350,250,20,20,NULL); +G.drawimage (Gameutill.getimage ("Com/neuedu/img/12.png"), 300,400,20,20,NULL); -G.drawimage (Gameutill.getimage ("Com/neuedu/img/13.png"), 400,300,20,20,NULL); $G.drawimage (Gameutill.getimage ("Com/neuedu/img/14.png"), 200,250,20,20,NULL); $G.drawimage (Gameutill.getimage ("Com/neuedu/img/15.png"), 100,200,20,20,NULL); - - the } - Public Static voidMain (string[] args) {WuyiTaiqiu TQ =NewTaiqiu (); the tq.loadframe (); - } Wu}
1 PackageCom.neuedu.utill;2 3 ImportJava.awt.Image;4 ImportJava.awt.image.BufferedImage;5 Importjava.io.IOException;6 ImportJava.net.URL;7 8 ImportJavax.imageio.ImageIO;9 Ten Public classGameutill { One Public StaticImage getImage (String imgpath) { AURL u = gameutill.class. getClassLoader (). getresource (Imgpath); -BufferedImage img =NULL; - Try { theIMG =imageio.read (u); -}Catch(IOException e) { - //TODO auto-generated Catch block - e.printstacktrace (); + } - returnimg; + A } at}
Java GUI simple Billiard Game Model