I have ported some JAVA Apps from Windows 10 onto Ubuntu 22.04 (it runs alongside with Windows). Some data:
- Acer e15. 360 GB Ubuntu-partition
- Java JDK-9.0.4 (I won't move up due to one fact that JavaFX is a part of JDK and it saves me to deal with Open JavaFX) for both Windows and Ubuntu.
Most of the apps work fine. However I have noticed that JavaFX GraphicsContext won't work with Image on Ubuntu. On Windows 10 it works fine. The codes are
scopter = new Image(getClass().getResourceAsStream("scopter.jpg"));
Canvas screen = new Canvas(580, 500);
gc = screen.getGraphicsContext2D();
...
private void draw( ) {
gc.setFill(Color.BLACK);
gc.fillRect(0,0,580,580);
gc.setFill(Color.RED);
gc.drawImage(scopter, sX, sY); // <---Trouble is HERE
if (mode) { // pick-up mode
if (home > 1) { // chopper home
gc.fillOval(cX, cY, 15, 15);
} else if (home > 0) { // cargo home
gc.fillOval(sX+DX, sY+DY, 15, 15);
} else { // on fetching cargo
if (home < 0) { // outbound
gc.setStroke(Color.RED);
gc.fillOval(cargoX, cargoY, 15, 15);
gc.strokeText("Invalid Cargo Location.", 200, 250);
} else gc.fillOval(cX, cY, 15, 15);
}
} else { // delivery mode
if (home > 0) { // chopper home
gc.fillOval(dX, dY, 15, 15);
} else { // on fetching cargo
if (home < 0) { // outbound
gc.setStroke(Color.RED);
gc.fillOval(cargoX, cargoY, 15, 15);
gc.strokeText("Invalid Cargo Location.", 200, 250);
} else {
if (delivery > 0) {
gc.fillOval(sX+DX, sY+DY, 15, 15);
} else gc.fillOval(cargoX, cargoY, 15, 15);
}
}
if (dX > 0) {
gc.setFill(Color.WHITE);
gc.fillOval(dX+5, dY+5, 5, 5);
}
}
gc.setLineWidth(1);
gc.setStroke(Color.YELLOW);
gc.strokeText("FuzzyLogic Controlled Aerial Chopper - Joe Nartca (C) -", 124, 15);
gc.strokeText(String.format("Speed %3.2f, Chopper %3.2f / %3.2f (cargo %3.2f / %3.2f)",
speed, sX, sY, cX, cY), 108, 30);
gc.setStroke(Color.CYAN);
gc.strokeText(String.format("Distance to TARGET and GOAL %3.2f / %3.2f",
deltaX, deltaY),5, 495);
if (oX != 0) {
gc.setFill(Color.web("#a9ff00"));
gc.fillOval(oX, oY, 20, 20);
}
}
The Screen layout And as one can see that the scopter image aside the red ball won't show up. The question is: is it a glitch of Ubuntu 22.04 or of JavaFX-linux?
PS: And here is the Image on Windows