-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractise$1.java
More file actions
45 lines (39 loc) · 1.63 KB
/
Copy pathPractise$1.java
File metadata and controls
45 lines (39 loc) · 1.63 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package Src;
import java.awt.Component;
import java.awt.Font;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.filechooser.FileNameExtensionFilter;
final class Practice$1 implements Runnable {
Practice$1() {
}
public void run() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(new FileNameExtensionFilter("Images", new String[]{"jpg", "gif", "png"}));
while(fileChooser.showOpenDialog((Component)null) == 0) {
try {
File f = fileChooser.getSelectedFile();
BufferedImage image = ImageIO.read(f);
if (image == null) {
throw new IllegalArgumentException(f + " is not a valid image.");
}
String ascii = (new Practice()).convert(image);
JTextArea textArea = new JTextArea(ascii, image.getHeight(), image.getWidth());
textArea.setFont(new Font("Monospaced", 1, 5));
textArea.setEditable(false);
JDialog dialog = (new JOptionPane(new JScrollPane(textArea), -1)).createDialog(Practice.class.getName());
dialog.setResizable(true);
dialog.setVisible(true);
} catch (Exception var7) {
JOptionPane.showMessageDialog((Component)null, var7.toString(), "Error", 0);
}
}
System.exit(0);
}
}