javafx

Switching scene in javaFX

情到浓时终转凉″ 提交于 2020-01-01 05:16:18
问题 I have problem when trying to close current scene and open up another scene when menuItem is selected. My main stage is coded as below: public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("Shop Management"); Pane myPane = (Pane)FXMLLoader.load(getClass().getResource ("createProduct.fxml")); Scene myScene = new Scene(myPane); primaryStage.setScene(myScene); primaryStage.show(); } Then within createProduct.fxml, when menuItem is onclick, it will perform this: public

JavaFX.MediaPlayer over HTTPS?

烈酒焚心 提交于 2020-01-01 04:56:26
问题 I tried to use MediaPlayer to play back a resource defined an HTTPS url, and it says protocol not supported. In the API reference they state FILE/HTTP/JAR are supported protocols (HTTPS not mentioned). Is it possible to somehow use urls via HTTPS? This seems quite a big drawback in my opinion... 回答1: This was fixed for Java 9, and later backported to Java 8. Java 8 update 91 and later should therefore be working with HTTPS URLs without an issue. If you're using an old version of Java that

How does JavaFX 8 start the JavaFX Application thread in a nearly empty Application class?

戏子无情 提交于 2020-01-01 04:54:12
问题 Lets say, we have the following class: import javafx.application.Application; import javafx.stage.Stage; public class Test extends Application { public Test() { System.out.println("Constructor"); } @Override public void start(Stage primaryStage) throws Exception { System.out.println("start"); } public static void main(String... args) { System.out.println("main"); } } It's derived from Application but it doesn't use any of its methods. Usually you start a JavaFX application by calling launch

Creating tray icon using JavaFX

为君一笑 提交于 2020-01-01 04:43:29
问题 I want to write a tray icon via JavaFx , but I only find that can write by awt . Is there any way that can write it use JavaFx ? It will look like these tray icons from Windows 10: 回答1: If this is to be believed, JavaFX will feature tray icons in a future update. Till then stick to AWT. Keep track of the development using this thread on the JDK bug system. Hope this helps. 回答2: You can't with pure JavaFX, but you can use AWT with JavaFX: import javafx.application.*; import javafx.geometry.Pos

How to drag an undecorated window (stage) of JavaFX

百般思念 提交于 2020-01-01 04:35:07
问题 I have this undecorated window: public static void initStartPage(final Stage primaryStage) { final Stage startPage = new Stage(); startPage.initStyle(StageStyle.UNDECORATED); //startPage.initOwner(primaryStage); //startPage.toFront(); Scene scene = new Scene(agentsPanel(), 900, 500); startPage.setScene(scene); startPage.show(); } I would like to know how I can make it a draggable undecorated window ? I want to change its position when the user selects the window with the right mouse button

JavaFX IllegalAccessException during FXML load()

若如初见. 提交于 2020-01-01 04:18:15
问题 I have a dialog window that is invoked by the following code ( DialogController is a helper class for using modal dialog windows; it mainly bundles together a controller reference with its window): void handleServicesEdit(ActionEvent event) throws IOException { DCServRecEditor sre = DialogController.<DCServRecEditor>loadFXML( CensusAssistant.RES_FXML_DIALOG_SERVEDIT, CensusAssistant.RES_STRING_SERVEDIT, this.getDialog()); sre.setDialogMode(DB.DBEDIT_MODE_EDIT, tbvService.getItems(),

Differences between ComboBox and ChoiceBox in JavaFX

烈酒焚心 提交于 2020-01-01 03:58:08
问题 What are the differences between ComboBox and ChoiceBox in JavaFX? I'm not entirely clear on that just from the Javadoc for both classes. At the end of the day, I need a dropdown control that can be repopulated dynamically at runtime (I've got a database on the backend). For all cases in my application, I only need to select one item from the dropdown menus. The user also shouldn't be able to add an option to the dropdown menu from the screens they are visible on. My understanding is that

JavaFX: Styling application with CSS Selectors

拜拜、爱过 提交于 2020-01-01 03:05:27
问题 I have a couple of questions about styling a JavaFX application with CSS Selectors (such as: .table-view for every TableView ). I have created a main CSS-file, in which I want to define the universal style properties for my application. For example: every TableView gets the same color in every screen. I just import the Main.css in every .css that is associated with a .fxml file. Now I would like to style every HBox in a 'sidebar' the same way. I have tried it like this (as suggested in Oracle

JavaFX: Styling application with CSS Selectors

谁说胖子不能爱 提交于 2020-01-01 03:05:09
问题 I have a couple of questions about styling a JavaFX application with CSS Selectors (such as: .table-view for every TableView ). I have created a main CSS-file, in which I want to define the universal style properties for my application. For example: every TableView gets the same color in every screen. I just import the Main.css in every .css that is associated with a .fxml file. Now I would like to style every HBox in a 'sidebar' the same way. I have tried it like this (as suggested in Oracle

What is “automatic injection of location and resources properties into the controller” in JavaFX?

和自甴很熟 提交于 2020-01-01 02:54:47
问题 In the description of Initializable interface it is said: NOTE This interface has been superseded by automatic injection of location and resources properties into the controller. FXMLLoader will now automatically call any suitably annotated no-arg initialize() method defined by the controller. It is recommended that the injection approach be used whenever possible. The question is: how to "suitable annotate" methods? I find only one annotation -- @FXML . Are there any others? 回答1: The answer