Results 1 to 3 of 3
  1. #1
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    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:
    Java Code:
    chooser.setFileView(new FileIconView(filter, new ImageIcon("C:\\icons\\exit.png"))); //FIX
    
    ...
    
    [B]which calls[/B]
    
    ...
    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.

    :confused:
    Attached Files Attached Files

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java 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:
    Java Code:
    icon = new ImageIcon(icon.getImage()[b])[/b]
               .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.
    Java Code:
    icon = new ImageIcon(icon.getImage()
               .getScaledInstance(getWidth(),-1,Image.SCALE_DEFAULT));
    setIcon(icon);
    Error 2:
    Java 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
    Java Code:
    int result = chooser.showOpen[b]File[/b]Dialog(ImageViewFrame.this);
    to
    Java Code:
    int result = chooser.showOpenDialog(ImageView[b]er[/b]Frame.this);

  3. #3
    jon80's Avatar
    jon80 is offline Senior Member
    Join Date
    Feb 2008
    Location
    Malta (EU)
    Posts
    211
    Rep Power
    7

    Default

    Thank you I would never have seen my errors, for some reason :)

Similar Threads

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •