javafx

Using Unicode characters with JavaFX

为君一笑 提交于 2019-12-31 01:50:27
问题 I've been playing around with swing for some time and decided to check out FX now. So far I'm finding it a lot easier and more fun to work with as compared to swing but I've run into a small speed bump and after hours of looking around I just can't find a solution. I am unable to use \u when I try to add it through the fxml file It works fine if I don't use the fxml but I want to use the scene builder as it is more convenient. Here's the small piece of code: <?xml version="1.0" encoding="UTF

Is it possible to set a JavaFX static property in CSS?

夙愿已清 提交于 2019-12-31 01:50:25
问题 Sample FXML with the BorderPanel.alignment "static property": <BorderPane> <top> <Label text="My Label" BorderPanel.alignment="CENTER"/> </top> </BorderPane> The CSS-supported version: <BorderPane stylesheets="Style.css"> <top> <Label text="My Label" styleClass="labelClass"/> </top> </BorderPane> Style.css would be: .labelClass { -fx-borderpanel-alignement: center } 回答1: For JavaFX versions 2.0 to 2.2 => no you cannot set the static layout properties via css. You can create a feature request

Netbeans Java (JavaFX) Native Packaging with additional files and folders

痴心易碎 提交于 2019-12-31 01:46:29
问题 How to include additional files and folders (configuration files) when natively packaging Java applications? When building the project, I have set the build file to create directories and copy additional files to the dist directory. My normal builds (without native packaging) would result to this directory structure: -> dist -> lib -> application.jar -> config folder //additional folder -> another additional folder //additional folder Now, I would like to build my native installer (setup)

Creating a large body of text with different styles - JavaFX FXML

老子叫甜甜 提交于 2019-12-30 22:51:35
问题 In the fxml class of my JavaFx application I want to add a large body of text using minimal components (instead of adding multiple labels per line). I would also like to create varying styles of text in the same component. What component should I use (e.g TextArea) and how would I go about create multiple styles inside it (using css). 回答1: Use a TextFlow and add Text to it. You can style individual Text component with different style using css on them. Complete example : import javafx

JavaFX : Rotated animation delay between cycles

风格不统一 提交于 2019-12-30 18:55:58
问题 I've created an animation for an ImageView based on a RotatedTranstion using the following code : ImageView icon = ImageCache.getImage("refresh.png"); RotateTransition rotateTransition = new RotateTransition(Duration.millis(2000), icon); rotateTransition.setByAngle(360.0); rotateTransition.setCycleCount(Timeline.INDEFINITE); rotateTransition.play(); This results in the following animation : Rotation in Action As you may have noticed in the animated gif, the animation is not continuous i.e

JavaFX KeyEvent returns KeyCode.UNDEFINED

爷,独闯天下 提交于 2019-12-30 18:27:13
问题 I created a simple JavaFX application that receives input from the user in a TextField. I attached the KeyTyped event from SceneBuilder to the controller. My function looks like this: @FXML private void keyTyped(KeyEvent event) { System.out.println(event.getCode().equals(KeyCode.ENTER)); } This function always prints out UNDEFINED when I type the enter key. Any ideas on how to fix this? Other letters I type seem to have the same problem as well. 回答1: KeyTyped is a special event. It doesn't

JavaFX PopOver From ControlFX

有些话、适合烂在心里 提交于 2019-12-30 17:56:11
问题 Can someone write a short JavaFX example of a Popover from ControlFX ? I haven't been able to get it to work. Any help is greatly appreciated! 回答1: you must google out for that many sites are available nowadays https://bitbucket.org/controlsfx/controlsfx/commits/dca9619e05de26d176aaafe785c3b94f022562ef https://bitbucket.org/controlsfx/controlsfx/pull-request/158/initial-commit-of-popover-control/activity and etc. just Google out. Here we have program known as "HelloPopOver". import javafx

Obfuscating JavaFX application

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 13:43:12
问题 Since fxml-files uses Controller classes for events, how is it possible to obfuscate an JavaFX application? When the obuscated conntroller classes have different names and paths, the fxml files can't locate them. Editing the fxml files after obfuscating is not the solution i am searhing for. Is there another option? 回答1: No point reinventing the wheel; A quick google search yielded this website. It uses the Proguard obfuscator. 来源: https://stackoverflow.com/questions/24344768/obfuscating

JavaFx:What if I want to do something after initialize(),before the scene show,how can I achieve this?

让人想犯罪 __ 提交于 2019-12-30 11:55:07
问题 I want to do something ,after the controller's initialize() method done,but before the scene show.Is there any method will be invoked before the scene show?I want to put some code into the method. FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("sample.fxml")); AnchorPane pane = loader.load(); Scene gameScene = new Scene(pane); //I load a secne above,the I will get the controller,set some properties,then,use the properties to read a file before the secene show.

How can I make JavaFX web browser displays alert and confirm message

天涯浪子 提交于 2019-12-30 11:12:48
问题 My java web browser don't display alert("message"); and confirm("message"); either, I ussually use c# web Browser component and it's works perfectly but I'm new at this. public void openPage(String url){ JFXPanel jfxPanel = new JFXPanel(); JFrame frame = new JFrame(""); frame.add(jfxPanel); Platform.runLater(() -> { WebView webView = new WebView(); jfxPanel.setScene(new Scene(webView)); webView.getEngine().load(url); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setLocationRelativeTo