Reputation: 577
In my first approach to JavaFX, the scene is mistakenly displayed and I not find the cause. For example, the following code is proposed in the first basic tutorial from E(fx)clipse's page:
package Aplicacion;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Prueba extends Application {
@Override
public void start(Stage primaryStage) {
BorderPane p = new BorderPane();
Text t = new Text("Hello FX");
t.setFont(Font.font("Arial", 60));
t.setEffect(new DropShadow(2,3,3, Color.RED));
p.setCenter(t);
primaryStage.setScene(new Scene(p));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
It should display the text "Hello FX", but shows the following:
My Java version is 8u65 for Windows 64 (Win 7).
Upvotes: 0
Views: 141
Reputation: 159341
It's an Environmental Issue
Likely JavaFX is incompatible with your video card and drivers.
Workaround
To workaround the rendering bug on your machine, explicitly disable the hardware rendering pipeline for JavaFX and only use the software rendering pipeline:
-Dprism.order=sw
using a java -D
property.
The behaviour you experienced seems buggy
The behavior looks like a bug. I think that, in the case of an unsupported graphics card, JavaFX is supposed to exit with an unsupported error or fall back to a software rendering pipeline rather than display garbled junk. You may wish to file a bug report at http://bugreport.java.com.
If you file a bug report so ensure that you include all information about the machine used for testing:
You might also want to try updating your video card drivers and seeing if that fixes the issue.
Gate usage of conditional features using Platform.isSupported
Effects are conditional features, ensure you check if the the EFFECT
conditional feature is enabled for your system before you try to use an effect. Use Platform.isSupported:
if (Platform.isSupported(ConditionalFeature.EFFECT)) {
// use effects
}
If this fixes your issue, it is still an issue with the underlying JavaFX system as documentation states:
Using a conditional feature on a platform that does not support it will not cause an exception. In general, the conditional feature will just be ignored. See the documentation for each feature for more detail.
which is not occurring in your case.
Upvotes: 1