-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPictureViewer.java
More file actions
58 lines (46 loc) · 1.53 KB
/
PictureViewer.java
File metadata and controls
58 lines (46 loc) · 1.53 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
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.io.*;
/**
* This class includes methods for displaying the image in a window on
* the screen
*/
public class PictureViewer extends JFrame {
private static final long serialVersionUID = 1L;
JPanel contentPane;
JLabel imageLabel = new JLabel();
JLabel headerLabel = new JLabel();
/**
* Constructor.
*/
public PictureViewer() {}
/**
* Display the picture in a window on the screen.
*/
public void show (String fileName) throws MultimediaException {
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
contentPane = (JPanel) getContentPane();
contentPane.setLayout(new BorderLayout());
setTitle(fileName);
//ImageIcon imicon = new ImageIcon(this.getClass().getResource(fileName));
ImageIcon imicon = new ImageIcon(fileName);
imageLabel.setIcon(imicon);
contentPane.add(imageLabel, java.awt.BorderLayout.CENTER);
this.pack();
this.setVisible(true);
/* System.out.print("Press RET to continue");
BufferedReader keyboard = new BufferedReader
(new InputStreamReader(System.in));
String c = keyboard.readLine(); */
}
catch (Exception exception) {
throw new MultimediaException ("Error opening image file "+fileName);
}
//this.dispose();
}
}