• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

FadeTransition in javaFX

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, please I need help with some code here. I added image using scene builder in Javafx and want to add FadeTransition to it to serve as a splashScreen. I wrote the following code in my "SplashScreenController.java" file but it didn't fade the image.

public class SplashScreenController.java implements Initializable{

private Label label; @FXML private ImageView image;

private void handleButtonAction(Action Event event{

System.out.println("you clicked me!) ; label.setText("Hello World!")

}

@overide

public void initialize(URL url, Resource Bundle rb) {

FadeTransition fadeTransition= new FadeTransition (Duration.millis(5000), image) ;

fadeTransition.setFromValue(1.0); fadeTransition.setToValue(0);

fadeTransition.play();

}

}

But it didn't work although after running the image appears but the transition is not effected and no error messages.
 
Marshal
Posts: 66637
251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I merged your stuff with the following thread. I hope that is okay by you.
 
Faruk Aminu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, please I need help with some code here. I added image using scene builder in Javafx and want to add FadeTransition to it to serve as a splashScreen. I wrote the following code in my "SplashScreenController.java" file but it didn't fade the image.

   public class SplashScreenController.java implements
   Initializable{

   private Label label;
   @FXML
   private ImageView image;

   private void handleButtonAction(Action Event event{

   System.out.println("you clicked me!) ;
   label.setText("Hello World!")

   }

   @overide

   public void initialize(URL url, Resource Bundle rb) {

   FadeTransition fadeTransition= new FadeTransition
   (Duration.millis(5000), image) ;

   fadeTransition.setFromValue(1.0);
   fadeTransition.setToValue(0);

   fadeTransition.play();

   }

   }

But it didn't work although after running the image appears but the transition is not effected and no error messages.
 
Campbell Ritchie
Marshal
Posts: 66637
251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You appear to have the same problem in both instances; please give us more details about what goes wrong.
 
Faruk Aminu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes please I mistakenly sent double due to network problem. I want to build an application called Hotel Management System which I want to begin with a Splash Screen that comes up with an image while the application is loading.

I want to splash screen to appear with the image and then fade it in from opacity of 1 to 0 in 5 seconds. To achieve that I created a project in netbeans javafx with three files,

HotelManagementSystem.java
SplashScreen.fxml
SplashScreenController.java

I double clicked SplashScreen.fxml to open scene builder, where I added an imageView and created controller class for the image view and saved an image for the splashScreen.

I returned to netbeans to and run HotelManagementSystem.java and the image I saved in scene builder came up successfully and now I wanted to add a FadeTransition to animate it from opacity 1 to opacity 0.

I went to SplashScreenController.java, right click on SplashScreen.fxml and "make controller" then typed in this code:


    public class SplashScreenController.java implements
    Initializable{

    private Label label;
   
    @FXML

     private ImageView image;

    private void handleButtonAction(Action Event event{

    System.out.println("you clicked me!) ;
    label.setText("Hello World!")

    }

    @overide

    public void initialize(URL url, Resource Bundle rb) {

    FadeTransition fadeTransition= new FadeTransition
    (Duration.millis(5000), image) ;

    fadeTransition.setFromValue(1.0);
    fadeTransition.setToValue(0);

    fadeTransition.play();

    }

    }


I returned to HotelManagementSystem.java to build again but after running, only the image appeared again without the fade in transition effected, please help figure out where I was missing it.
 
Faruk Aminu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using windows 8, 64bits,  java8, netbeans 8.1 and scenebuilder
 
Sheriff
Posts: 6456
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This works for me.
This is called an SSCCE (that's a link).  It's good to write these to isolate the problem.
 
Faruk Aminu
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Woow, it worked. Thanks a lot
 
Knute Snortum
Sheriff
Posts: 6456
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a note: You don't have to write Duration.millis(5000), you can just write Duration.seconds(5).
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!