Closed BigFish90 closed 4 years ago
Could you please provide a code example of what you have tried so that I can reproduce it please? To run Medusa 11 you need for example OpenJDK11 in combination with OpenJFX from Gluon.
Hello HanSolo, the code is below:
`import eu.hansolo.medusa.Gauge;
import eu.hansolo.medusa.GaugeBuilder; import eu.hansolo.medusa.TickLabelOrientation; import eu.hansolo.medusa.skins.ModernSkin; import eu.hansolo.medusa.skins.SpaceXSkin; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage;
/*
@author Cool IT Help */ public class MedusaGuage extends Application {
@Override public void start(Stage primaryStage) { Gauge gauge = new Gauge(); Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setTranslateX(10); btn.setTranslateY(200);
//button click action handler
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
gauge.setAnimated(true);
gauge.setValue(90.00);
}
});
gauge.setSkin(new ModernSkin(gauge)); //ModernSkin : you guys can change the skin
gauge.setTitle("COOL IT HELP"); //title
gauge.setUnit("Km / h"); //unit
gauge.setUnitColor(Color.WHITE);
gauge.setDecimals(0);
gauge.setValue(50.00); //deafult position of needle on gauage
gauge.setAnimated(true);
//gauge.setAnimationDuration(500);
gauge.setValueColor(Color.WHITE);
gauge.setTitleColor(Color.WHITE);
gauge.setSubTitleColor(Color.WHITE);
gauge.setBarColor(Color.rgb(0, 214, 215));
gauge.setNeedleColor(Color.RED);
gauge.setThresholdColor(Color.RED); //color will become red if it crosses thereshold value
gauge.setThreshold(85);
gauge.setThresholdVisible(true);
gauge.setTickLabelColor(Color.rgb(151, 151, 151));
gauge.setTickMarkColor(Color.WHITE);
gauge.setTickLabelOrientation(TickLabelOrientation.ORTHOGONAL);
StackPane root = new StackPane();
root.getChildren().addAll(gauge);
root.getChildren().addAll(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Guage Example");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
} `
Your code works fine, so the problem seems to be related to your JavaFX setup. Please check openjfx.io to make sure your setup of OpenJDK + OpenJFX is correct. I've also modified your code a bit so that is makes use of the GaugeBuilder.
import eu.hansolo.medusa.Gauge.SkinType;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class Test extends Application {
private Gauge gauge;
private Button btn;
@Override public void init() {
gauge = GaugeBuilder.create()
.skinType(SkinType.MODERN)
.title("COOL IT HELP") //title
.unit("Km / h") //unit
.unitColor(Color.WHITE)
.decimals(0)
.value(50.00) //deafult position of needle on gauage
.animated(true)
//.animationDuration(500)
.valueColor(Color.WHITE)
.titleColor(Color.WHITE)
.subTitleColor(Color.WHITE)
.barColor(Color.rgb(0, 214, 215))
.needleColor(Color.RED)
.thresholdColor(Color.RED) //color will become red if it crosses thereshold value
.threshold(85)
.thresholdVisible(true)
.tickLabelColor(Color.rgb(151, 151, 151))
.tickMarkColor(Color.WHITE)
.tickLabelOrientation(TickLabelOrientation.ORTHOGONAL)
.build();
btn = new Button("Say 'Hello World'");
btn.setTranslateX(10);
btn.setTranslateY(200);
//button click action handler
btn.setOnAction(event -> {
System.out.println("Hello World!");
gauge.setValue(90.00);
});
}
@Override public void start(Stage primaryStage) {
StackPane root = new StackPane(gauge, btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Gauge Example");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Closed because the problem is not related to Medusa but to the JavaFX setup
Hello sir, I use : Eclipse IDE for Java Developers Version: 2019-12 (4.14.0) Build id: 20191212-1212
What should i do?
I have tried to use different versions of medusa.jar (8.0, 8.3, 11.1, 11.3) with differents jre (8, 9, 10), but i get in the consol almost same error:
Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:473) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:372) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:945) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:973) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:198) at java.base/java.lang.Thread.run(Thread.java:844) Caused by: java.lang.NoClassDefFoundError: eu/hansolo/medusa/Gauge at medusaguage.MedusaGuage.start(MedusaGuage.java:29) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175) ... 1 more Caused by: java.lang.ClassNotFoundException: eu.hansolo.medusa.Gauge at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ... 10 more Exception running application medusaguage.MedusaGuage