|
Code:
|
C:\jexp\jon\src\homenetwork\bkr\training>javac *.java
ImagePreviewer.java:35: cannot find symbol
symbol : method getScaledInstance(int,int,int)
location: class javax.swing.ImageIcon
if (icon.getIconWidth() > getWidth()) icon = new ImageIcon(icon.getIma
ge()).getScaledInstance(getWidth(),-1, Image.SCALE_DEFAULT);
^
ImageViewerFrame.java:59: setFileView(javax.swing.filechooser.FileView) in javax.swing.JFi
leChooser cannot be applied to (FileIconView)
chooser.setFileView(new FileIconView(filter, new ImageIcon("icons/exit.png"))); //
FIX
^
ImageViewerFrame.java:72: cannot find symbol
symbol : class ImageViewFrame
location: class ImageViewerFrame.FileOpenListener
int result = chooser.showOpenFileDialog(ImageViewFrame.this);
^
3 errors |
Error 1:
|
Code:
|
icon = new ImageIcon(icon.getImage())
.getScaledInstance(getWidth(),-1,Image.SCALE_DEFAULT); |
You've misplaced a right parenthesis ")". The
getScaledInstance method is being called on the ImageIcon instance instead of on its image argument.
|
Code:
|
icon = new ImageIcon(icon.getImage()
.getScaledInstance(getWidth(),-1,Image.SCALE_DEFAULT));
setIcon(icon); |
Error 2:
|
Code:
|
chooser.setFileView(new FileIconView(filter,
new ImageIcon("icons/exit.png"))); |
The argument for the
setFileView method is/must be a FileView object.
You are supplying something unrelated. You might consider having the FileIconView class extend the FileView abstract class.
Error 3:
Typos.
Change
|
Code:
|
int result = chooser.showOpenFileDialog(ImageViewFrame.this); |
to
|
Code:
|
int result = chooser.showOpenDialog(ImageViewerFrame.this); |