《uml建模技术-图书管理系统为例建模过程3.rtf》由会员分享,可在线阅读,更多相关《uml建模技术-图书管理系统为例建模过程3.rtf(6页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、22-1import java.applet.*;import java.awt.*;public class Example22_1 extends Applet Image img;public void start()img=getImage(getCodeBase(),vintdev.jpg);public void paint(Graphics g)g.drawImage(img,2,2,this);22-2import java.applet.*;import java.awt.*;public class Example22_2 extends Applet Image img;
2、int height,width;public void start()img=getImage(getCodeBase(),vintdev.jpg);height=img.getHeight(this);width=img.getWidth(this);public void paint(Graphics g)g.drawImage(img,22,72,width,height,this);g.drawImage(img,2+width,2+height,width,height,this);22-3import java.applet.*;import java.awt.*;public
3、class Wuqiong extends Applet static Image img;Canvas canvas;static int width,height;public void init()setLayout(new GridLayout(3,1);add(new Button();add(new Button();canvas=new Mycanvas();add(canvas);width=getSize().width;height=getSize().height;public void start()img=getImage(getCodeBase(),Tom1.jpg
4、);class Mycanvas extends Canvas public void paint(Graphics g)g.drawImage(Wuqiong.img,0,0,Wuqiong.width,(Wuqiong.height)/3,this);22-4import java.applet.*;import java.awt.*;import java.awt.event.*;public class Example22_4 extends Applet implements MouseListenerfinal int number=38;int count=0;Image car
5、d=new Imagenumber;public void init()addMouseListener(this);for(int i=0;inumber)count=0;repaint();public void mouseReleased(MouseEvent e)public void mouseEntered(MouseEvent e)public void mouseExited(MouseEvent e)public void mouseClicked(MouseEvent e)22-5import java.applet.*;import java.awt.*;import j
6、ava.awt.event.*;public class Example22_5 extends Applet implements Runnablefinal int number=59;int count=0;Thread mythread;Image pic=new Imagenumber;public void init()for(int i=0;i59)count=0;repaint();count+;trymythread.sleep(200);catch(InterruptedException e)public void paint(Graphics g)if(piccount
7、)!=null)g.drawImage(piccount,10,10,piccount.getWidth(this),piccount.getHeight(this),this);22-6import java.applet.*;import java.awt.*;import java.awt.event.*;class Imagecanvas extends Canvas Toolkit tool;Image myimage;Imagecanvas()getSize();tool=getToolkit();/Toolkit myimage=tool.getImage(apple.jpg);
8、/tool public void paint(Graphics g)g.drawImage(myimage,10,10,myimage.getWidth(this),myimage.getHeight(this),this);public Dimension getPreferredSize()return new Dimension(160,100);public class Example22_6 public static void main(String args)Imagecanvas canvas=new Imagecanvas();Frame frame=new Frame()
9、;frame.setLayout(new BorderLayout();frame.add(canvas,Center);frame.add(South,new Label();frame.add(West,new Label();frame.add(North,new Label();frame.setSize(400,300);frame.setVisible(true);frame.pack();frame.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0)
10、;);22-7import java.applet.*;import java.awt.*;import java.awt.event.*;class Imagecanvas extends Canvas implements MouseListenerfinal int number=59;int count=0;Toolkit tool;Image card=new Imagenumber;Imagecanvas()getSize();tool=getToolkit();addMouseListener(this);for(int i=0;inumber-1)count=0;repaint
11、();public void mouseReleased(MouseEvent e)public void mouseEntered(MouseEvent e)public void mouseExited(MouseEvent e)public void mouseClicked(MouseEvent e)public class Example226 public static void main(String args)Imagecanvas canvas=new Imagecanvas();Frame frame=new Frame();frame.setLayout(new Bord
12、erLayout();frame.add(canvas,Center);frame.add(South,new Label();frame.add(West,new Label();frame.add(North,new Label();frame.setSize(400,300);frame.setVisible(true);frame.pack();frame.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););22-8import java.awt.*;
13、import java.awt.event.*;public class Frame_Icon public static void main(String args)Frame frame=new Frame();Toolkit tool=frame.getToolkit();/Toolkit Image myimage=tool.getImage(apple.jpg);/tool /myimageapple.jpg frame.setIconImage(myimage);frame.setSize(400,300);frame.setVisible(true);frame.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent e)System.exit(0););