Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2009, 04:37 PM
jon80's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 195
Rep Power: 2
jon80 is on a distinguished road
Default [SOLVED] method not applicable for the arguments
I have a littel problem with the code, since the arguments I am passing to a stub do not seem to be valid:
Code:
chooser.setFileView(new FileIconView(filter, new ImageIcon("C:\\icons\\exit.png"))); //FIX

...

which calls

...
public void setFileView (FileIconView fileIconView) { //FIX
		//TODO stub
}

...
FileIconView is a class whose constructor requires:
public FileIconView(FileFilter aFilter, Icon anIcon)
	{
		filter = aFilter;
		icon = anIcon;
	}

...
NOTE 1: The code does not compile and might have other problems, but I have uploaded it as an attachment.

Attached Files:
File Type: zip src.zip (3.8 KB, 2 views)
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-31-2009, 02:49 AM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,561
Rep Power: 4
hardwired is on a distinguished road
Default
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);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-31-2009, 05:13 PM
jon80's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 195
Rep Power: 2
jon80 is on a distinguished road
Default
Thank you I would never have seen my errors, for some reason
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
method that return 2 arguments itaipee New To Java 19 01-12-2009 06:36 PM
Using final with method arguments Java Tip java.lang 0 04-17-2008 08:48 PM
Arguments in Main CyberFrog New To Java 2 03-30-2008 10:37 PM
repetition of 'arguments'(?) Igor New To Java 3 12-13-2007 11:08 AM
Variable No. of Arguments Gajesh Tripathi New To Java 2 10-31-2007 03:50 PM


All times are GMT +2. The time now is 07:04 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org