📄 fetchimage.java
字号:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;
class FetchImage extends Frame {
/* Fetch an image program by J M Bishop Jan 1997
* ====================== Java 1.1
* updated B Worrall Aug 2000
* Fetches a jpg or gif image into a window.
* Illustrates use of awt.image. */
private Image image;
public void paint(Graphics g) {
g.drawImage(image, 50, 50, this);
}
public static void main(String[] args) throws Exception {
new FetchImage(args[0]);
}
FetchImage (String name) throws Exception {
URL imageURL = new URL(name);
image = createImage((ImageProducer) imageURL.getContent());
setSize(300, 300);
setVisible(true);
addWindowListener(new WindowAdapter () {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -