javafx-8

Spell check text in TextArea

ぐ巨炮叔叔 提交于 2019-12-01 18:12:52
How I can spell check text typed from the user into TextArea? Is this possible with this JavaFX component? Can I use standard spellchecker from Java for JavaFX? You can use CodeArea to highlight the errors. CodeArea codeArea = new CodeArea(); codeArea.textProperty().addListener((observable, oldText, newText) -> { List<IndexRange> errors = spellCheck(newText); for(IndexRange error: errors) { codeArea.setStyleClass(error.getStart(), error.getEnd(), "spell-error"); } }); List<IndexRange> spellCheck(String text) { // Implement your spell-checking here. } In addition, set the error style in your

Spell check text in TextArea

若如初见. 提交于 2019-12-01 17:31:20
问题 How I can spell check text typed from the user into TextArea? Is this possible with this JavaFX component? Can I use standard spellchecker from Java for JavaFX? 回答1: You can use CodeArea to highlight the errors. CodeArea codeArea = new CodeArea(); codeArea.textProperty().addListener((observable, oldText, newText) -> { List<IndexRange> errors = spellCheck(newText); for(IndexRange error: errors) { codeArea.setStyleClass(error.getStart(), error.getEnd(), "spell-error"); } }); List<IndexRange>

Remove all children from a group without knowing the containing nodes

天大地大妈咪最大 提交于 2019-12-01 16:14:36
check this out Group g = new Group(); GridPane grid = new GridPane(); // g.getChildren().addAll(grid); now my question is how do i remove this "grid" from "g" without specifying "grid" like something like this g.getChildren().removeAll(null); //i do not know what to insert here? thanks in advance If you want to remove all items from a collection, use the clear() method: g.getChildren().clear(); 来源: https://stackoverflow.com/questions/27066484/remove-all-children-from-a-group-without-knowing-the-containing-nodes

FXML Variables not binding

一笑奈何 提交于 2019-12-01 14:47:23
I am having an issue with my FXML injection. I have setup my program as far as I can tell but it seems that I am missing something. My code is below: Main: package application; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; public class Main extends Application { @Override public void start(Stage primaryStage) { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("NoteKeeper.fxml")); BorderPane root = (BorderPane)loader.load(); Scene scene =

JavaFX : Integrating Spring framework with JavaFX app(Incorrect configuration)

爷,独闯天下 提交于 2019-12-01 14:30:33
I am working on a JavaFX application and I would like to integrate Spring functionality with it. Currently the code compiles without any error, but when I request service layer methods which are tagged as @Transactional and @Service, I get NullPointerException. What am I doing wrong in the Spring configuration is what I dont understand. Here is my code for JavaFX : Main class : public class Main extends Application { private static final SpringFxmlLoader loader = new SpringFxmlLoader(); @Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass()

Creating a row index column in JavaFX

女生的网名这么多〃 提交于 2019-12-01 13:59:43
I have a JavaFX TableView that I'm populating with an ObservableList of Tasks. I've been trying to create a column that displays the index of each row, which serves as the ID for the tasks in the table, but I've tried the method here and similar methods from other sources with little success. My code for reference, which has no superficial errors (as far as Eclipse can tell): @FXML private TableColumn<Task, String> taskIndexCol; Callback<TableColumn<Task, String>, TableCell<Task, String>> cb = new Callback<TableColumn<Task, String>, TableCell<Task, String>>(){ @Override public TableCell<Task,

Skinning custom 3D cube in javafx 8

大憨熊 提交于 2019-12-01 13:00:36
I am trying to add a skin to a cube by using the following code, but the skin will not work at all. I tested to see if it will add to a default cube and it will (but repeats the full image on each side instead of wrapping around it, which is why I am making a custom cube to prevent this). Any help would be greatly appreciated. private void buildGraphics() { Image dieImage = new Image(getClass().getResourceAsStream("images/die.gif")); PhongMaterial material = new PhongMaterial(); material.setDiffuseMap(dieImage); material.setSpecularColor(Color.RED); float hw = 100/2f; float hh = 100/2f; float

JavaFX silently swallowing exception raised in drag listeners

风格不统一 提交于 2019-12-01 12:50:49
It appears that exceptions are silently swallowed in drag over listeners in JavaFX. I've searched and can't find any mention of this in the documentation. I've recreated this below... Is there anyway to prevent this and expose the exceptions? public class App extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { Button source = new Button("source"); Button destination = new Button("destination"); HBox box = new HBox(source, destination); source.setOnDragDetected(event -> { Dragboard db = source

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

不想你离开。 提交于 2019-12-01 12:30:31
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. GameUIController controller = loader.getController(); controller.setGameFileLoacation("game1.txt");//I

JavaFX silently swallowing exception raised in drag listeners

只谈情不闲聊 提交于 2019-12-01 11:39:05
问题 It appears that exceptions are silently swallowed in drag over listeners in JavaFX. I've searched and can't find any mention of this in the documentation. I've recreated this below... Is there anyway to prevent this and expose the exceptions? public class App extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { Button source = new Button("source"); Button destination = new Button("destination"); HBox