javafx

How to change slider range background color using css?

徘徊边缘 提交于 2019-12-24 20:32:55
问题 I currently have a slider that I am styling with CSS. What I want is the range to change color when the thumb is slid. Similar to this picture: How can I do this using only CSS? Below is what I have tried so far. .range-slider .range-bar { -fx-background-color: red; } 回答1: You can do this by using a linear-gradient for the track background, and binding the point where the gradient changes to the slider's value. The basic idea would be that when, e.g., the slider's value is at 50%, the

How to stop JavaFx Slider controls from resetting to their default values when switching between windows

我的未来我决定 提交于 2019-12-24 20:32:53
问题 I have a bunch of fxml windows that I built in SceneBuilder for javafx. When I switch between my settings window and my main menu the sliders (for various sound levels) reset to their original value, however i would want them to keep the values they were at last time the window was open. I've tried settings values in initialise and settings a variable through the class that is changed and used to set the sliders when it is launched, but that didn't work either. The FXML <!-- The slider code

Automatic module VM options for jar file

不打扰是莪最后的温柔 提交于 2019-12-24 20:22:24
问题 So I am currently playing around with the new changes in Java 11 and thus the external OpenJFX SDK. However I guess it would be much easier for me to distribute one single jar file and let users download their required SDK stuff on their own and put it into a predefined folder inside the same folder as my jar. Now I am asking myself whether it is possible to automatically add the required VM options on launch of my jar without requiring the users of my program to launch it from the console

JavaFX 3D PerspectiveCamera affects drag position of a node

こ雲淡風輕ζ 提交于 2019-12-24 20:17:12
问题 I have been having issues trying to move nodes in JavaFX within a 3D Scene. The issue is that I want the mouse to stay at the position within the node I've clicked, i.e., center. With a PerspectiveCamera it will alter the position. I've tried a couple of different methods and haven't had any luck. 2D Rectangles, and 3D Boxes(without a camera) work perfectly, but once a PerspectiveCamera is added, regardless of true/false parameter, I have issues. I am wondering if this a bug that should be

JavaFXML reference to Controller from all classes

和自甴很熟 提交于 2019-12-24 20:14:49
问题 I have my MainView class, which is the one that starts up the whole program. public class MainView extends Application { @Override public void start(Stage stage) throws IOException { stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { Platform.exit(); System.exit(0); } }); FXMLLoader loader = new FXMLLoader(getClass().getResource("NavigationView.fxml")); Parent root = loader.load(); Scene scene = new Scene(root); stage.setResizable(false);

Distributing/deploying JavaFX apps

一曲冷凌霜 提交于 2019-12-24 20:12:21
问题 I am just finishing up a little app in JavaFX and am starting to think about how to distribute it. I figured this would be a simple matter of hitting the build button and using one of the resulting files. For some reason build creates: Jar file which complains it can't find its main class when doubleclicked. A jnlp file which fails saying "unable to launch application". An html file which, when opened in my browser shows a spinning java logo forever. All of this leads me to believe that there

fxml loader exception “root value is already specified” I never specified a root value

女生的网名这么多〃 提交于 2019-12-24 19:50:18
问题 I am trying to have a hyperlink open a new window. I have copied the fxml loader method from other parts of my code that work without issue. For some reason I am getting an fxml loader exception issue that says the root value is already specified. I have not specified a root value anywhere in my code. I also have not specified a controller in the fxml because other answers on stackoverflow said this might be causing the issue. this is the class that is loading the new Window. the issue occurs

Showing a PNG file with transparent background using javafx

半腔热情 提交于 2019-12-24 19:44:10
问题 Am actually working on a splash Screen unsing javaFX, everythink works fine but I want to show a png image with a transparent background on the splash screen, but am unable to do it, can someone please tell me if it's possible to do it from JavaFX Scene Builder or not ? 回答1: I'm in a bit of a rush, but below is a quick example to show you how it can be done by setting the StageStyle to Transparent and the scene fill to the color "transparent". @Override public void start(Stage aStage) throws

How to hide full screen button of Mac OS window (in JavaFX)?

风流意气都作罢 提交于 2019-12-24 19:28:58
问题 Every window title bar of Mac OS has a full screen button at the top-right corner.Is there any way to hide this default full screen button of Mac OS in JavaFX? Here is my code snippet: public static void launchOkMessageBox(){ pane = new VBox(); scene = new Scene(pane,150,60, Color.GHOSTWHITE); Label label = new Label("Hello Word"); Button okButton = new Button("Ok"); pane.getChildren().add(label); pane.getChildren().add(okButton); pane.setAlignment(Pos.CENTER); pane.setSpacing(10);

JavaFx: show DatePicker

巧了我就是萌 提交于 2019-12-24 19:17:10
问题 I have a ComboBox<MyItem> and I want to show a DatePicker when I select a special item from the ComboBox . I created a class that extends ComboBox, and I have a DatePicker in that class. I have added a listener to its selectedItemProperty : public class CustomComboBox extends ComboBox<MyItem>{ private DatePicker datePicker; public CustomComboBox(){ getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (MyItem.DATE.equals(newValue)) { initDatePicker();