-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageProxyTestDrive.java
More file actions
29 lines (24 loc) · 1.17 KB
/
ImageProxyTestDrive.java
File metadata and controls
29 lines (24 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package ProxyPattern.VirtualProxyPattern.ImageProxy;
import java.net.*;
import javax.swing.*;
public class ImageProxyTestDrive {
ImageComponent imageComponent;
public static void main(String[] args) throws Exception {
ImageProxyTestDrive testDrive = new ImageProxyTestDrive();
// Adding a delay to keep the program running so you can see the loading state
// and then the loaded CD cover image before the program exits
Thread.sleep(20000); // 20 second delay (enough time to see 10s loading + 10s of the image)
}
public ImageProxyTestDrive() throws Exception {
JFrame frame = new JFrame("CD Cover Viewer");
// Using a placeholder image service for demonstration (picsum.photos provides free placeholder images)
// Alternative: You can replace this with any publicly accessible image URL
URL url = new URL("https://picsum.photos/400/400");
Icon icon = new ImageProxy(url);
imageComponent = new ImageComponent(icon);
frame.getContentPane().add(imageComponent);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
frame.setVisible(true);
}
}