?? changeimg.java
字號:
package untitled1;import java.awt.*;import java.awt.event.*;import java.applet.*;public class changeImg extends java.applet.Applet implements Runnable{ Image myImg; boolean flag1 = true; boolean flag = true; double i = 0.1; Thread runner; boolean isStandalone = false; /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } public void start(){ if(runner==null){ runner=new Thread(this); runner.start(); } } public void stop(){ if(runner!=null){ runner.stop(); runner=null; } } public void run(){ while(true){ repaint(); try{ Thread.sleep(200); } catch(InterruptedException e){} } } public void paint(Graphics g){ if (i >= 2.5) flag = false; if (i <= 0.1) flag = true; if (flag == true) i += 0.1; else i -= 0.1; int x = myImg.getWidth(this); int y = myImg.getHeight(this); g.drawImage(myImg,(150-(int)((x*i)/2)),(150-(int)((y*i)/2)),(int)(x*i),(int)(y*i),this); } /**Construct the applet*/ public changeImg() { } /**Initialize the applet*/ public void init() { myImg=getImage(getCodeBase(),"qingchengshan1.jpg"); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { this.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { this_mouseClicked(e); } }); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } public String[][] getParameterInfo() { return null; } void this_mouseClicked(MouseEvent e) { flag1 = !flag1; if (flag1==true) start(); else stop(); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -