Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Loading an image in ImageView through code javafx

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Location
    kathmandu, nepal
    Posts
    29
    My Mood
    Cheerful
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Loading an image in ImageView through code javafx

    I have built my application using scenebuilder for javafx. I have a form where a person has to upload an image. I used this code

     public void photoChooser(ActionEvent evt)
         {
             System.out.println("photoChooser method is called");
             try{
             FileChooser fileChooser= new FileChooser();
             fileChooser.setTitle("Choose a file");
             File file = fileChooser.showOpenDialog(stagehere);
             if(file != null){
                 System.out.println(file);
                 String img = file.toString();
                 //Image image = new ImageIcon(img);
                // String directory = "A://images//Images//041.JPG";
     
     
                 try{
     
             //    image= new Image();
                 Image image = new Image(img);
     
                 } catch (Exception e) {System.out.println("Can't upload image " + e);}
     
     
               //  Im
                 //employeeImage.setImage(image);
                 try{
                // employeeImage.setImage(image);
                 } catch(Exception e){System.out.println("Can't set the image" + e);}
                 employeeImage.setFitWidth(150);
                 employeeImage.setFitHeight(150);
             }

    And I get this error
     photoChooser method is called
    A:\images\fb\status\asd.jpg
    Can't upload image java.lang.IllegalArgumentException: Invalid URL: unknown protocol: a
    Last edited by viper_pranish; January 19th, 2014 at 05:05 AM. Reason: incomplete post


Similar Threads

  1. [SOLVED] Image not loading
    By Bebras in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: January 10th, 2014, 05:36 PM
  2. Problems With Image Loading and Extended Objects
    By Gravity Games in forum Object Oriented Programming
    Replies: 13
    Last Post: April 22nd, 2013, 01:31 PM
  3. loading my image
    By riddick_charel in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 26th, 2013, 06:12 AM
  4. ImageIcon Erratically Loading URL Image
    By aussiemcgr in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 3rd, 2011, 04:05 PM