⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imageapplet.java

📁 程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件
💻 JAVA
字号:
package examples.applet;
import javax.swing.*;
import java.awt.*;
/** An example applet that loads and displays an image
  */
public class ImageApplet extends JApplet {
   public void init() {
      Image image = getImage( getDocumentBase(),
                              getParameter( "image" ) );
      ImagePanel ip = new ImagePanel( image );
      setContentPane( ip );
   }
   public String getAppletInfo() {
      return "Demonstration applet";
   }
   public String[][] getParameterInfo() {
      String pInfo[][] = {
         { "image", "String",
           "The file containing the image."  }
      };
      return pInfo;
   }
   public class ImagePanel extends JPanel {
      private Image image;
      public ImagePanel( Image image ) {
         this.image = image;
      }
      public void paintComponent( Graphics g ) {
         Insets ins = getInsets();
         g.drawImage( image, ins.right, ins.top, this );
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -