fxml

RequestFocus in TextField doesn't work

落爺英雄遲暮 提交于 2019-12-04 16:29:35
问题 I use JavaFX 2.1 and I created GUI using FXML, in the controller of this GUI I added myTextField.requestFocus(); . But I always get the focus in the other control. 回答1: At the time of initialize() controls are not yet ready to handle focus. You can try next trick: @Override public void initialize(URL url, ResourceBundle rb) { Platform.runLater(new Runnable() { @Override public void run() { tf.requestFocus(); } }); } For tricky complex applications (like Pavel_K has in the comments) you may

View logic inside fxml (iterating in particular)

亡梦爱人 提交于 2019-12-04 16:12:38
So, here's an example fxml from yfiles developer's guide (not that important actually): <?xml version="1.0" encoding="UTF-8"?> <?import javafx.scene.layout.StackPane?> <?import javafx.scene.layout.VBox?> <?import javafx.scene.control.Label?> <?import com.yworks.yfiles.drawing.NodeTemplate?> <NodeTemplate fx:id="templateNode" style="-fx-background-color: darkblue" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8"> <VBox alignment="CENTER"> <Label fx:id="firstName" text="${templateNode.item.tag.firstName}" textFill="${templateNode.styleTag.firstNameColor}" /> <Label fx:id=

How to create skins(fxml) for buttons and other elements in JavaFX 2.0? [closed]

梦想与她 提交于 2019-12-04 14:51:31
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I am wondering if anyone has or knows a link from where I can learn or see how to create skins for buttons, radio buttons, scrollbars

How to remove the expand effect on button clicked JavaFX?

て烟熏妆下的殇ゞ 提交于 2019-12-04 12:22:55
How can I remove the small expand effect when I click on a JavaFX button? And also how can I make it work like an menu button (when I press it to remain in focused state untill I press another "menu" button). Is there a way to group nodes into the same focus? Three questions for the price of one ;-) How can I remove the small expand effect when I click on a JavaFX button? When you click the button it has focus, when it has focus, it is surrounded by the focus ring, which makes it slightly larger. This effect is triggered via css. Default css is in caspian.css found in jfxrt.jar in your JavaFX

How to limit the amount of characters a javafx textfield

拜拜、爱过 提交于 2019-12-04 11:42:37
问题 I´m using a FXML to set my form, but I need to set the limit of characters in textfields. How can I made this ? 回答1: Here is my solution to limit the length of a textfield. I would not recommend solutions which use a listener (on text property or on length property), they do not behave correctly in all situations (for what I have seen). I create an HTML input text with a max length, and compare it to my textfield in JavaFX. I had the same behavior with paste operations (Ctrl + V), cancel

JavaFX TextField : Automatically transform text to uppercase

梦想与她 提交于 2019-12-04 11:33:06
问题 I have a JavaFX TextField control on my FXMl that looks like this... <TextField fx:id="input_search" onKeyPressed="#keyListener" prefHeight="25.0" prefWidth="197.0" /> I want to automatically change all characters to uppercase when the user is typing. The code in my controller : public void keyListener(KeyEvent event){ //maybe transform the pressed key to uppercase here... } 回答1: There are a few ways to achieve this: Override replaceText() TextField textField = new TextField() { @Override

JavaFX 2.2 Modal window dialog *with* FXML

戏子无情 提交于 2019-12-04 10:59:41
I am trying to use the example provided by @jewelsea at this gist and I'm stuck because I'm using FXML. I have seen both of these posts: How to create a modal window in JavaFX 2.1 and this answer to JavaFX 2 modal window . Where I'm stuck is in the code by jewelsea, where it says: final WebView webView = new WebView(); webView.getEngine().load("http://docs.oracle.com/javafx/"); primaryStage.setScene(new Scene(webView)); Whereas, since I'm using FXML, I do this: FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MyFXML.fxml")); Scene scene = (Scene)fxmlLoader.load(); myController =

How to get parent Window in FXML Controller?

旧城冷巷雨未停 提交于 2019-12-04 09:13:53
问题 For example, I want open a DirectoryChooser when clicking on the button: <VBox fx:controller="com.foo.MyController" xmlns:fx="http://javafx.com/fxml"> <children> <Button text="Click Me!" onAction="#handleButtonAction"/> </children> </VBox> And the Controller class: package com.foo; public class MyController { public void handleButtonAction(ActionEvent event) { DirectoryChooser dc = new DirectoryChooser(); File folder = dc.showDialog(null);//I want to put the WIndows here. } } I want to put

How to style a SVG using CSS in javaFX FXML

廉价感情. 提交于 2019-12-04 08:50:24
I'm using SVG for an image in a button. But I'm not able to fill in color for it through CSS. Below is the code to render a button. <Button onAction="#closeApplication" > <graphic> <SVGPath content="M10,16 10,0 0,8z" styleClass="button‐icon‐shape" /> </graphic> </Button> here is the css .button-icon-shape SVGPath{ -fx-fill: red; } here is how it worked. I had to style the button and use the class to style the svg in the button. <Button onAction="#closeApplication" styleClass="closeButton"> <graphic> <SVGPath content="M10,16 10,0 0,8z" /> </graphic> </Button> here is the css .closeButton{ }

Netbeans7.1 & JavaFX 2.0 - FXML code completion doesn't work

戏子无情 提交于 2019-12-04 07:28:38
I started learning JavaFX 2.0 and installed Netbeans 7.1, java 7.02 SDK (wich contains JavaFX 2). Everything seems to work, the example projects compile and run fine. My problem is: Code completition doesn't work for FXML files. I press ctrl+space and it shows "No suggestions" every time. The same for tags and attributes. Does anyone know what could be the problem? You can still show autocomplete menu for attributes by pointing the cursor just beginning (or middle to show sublist) of the existing attribute and hitting ctrl+space. Also while writing tags, Netbeans suggests even automatically