javafx

JavaFX 8 loading multiple fxml files into borderpane

风格不统一 提交于 2019-12-28 07:08:11
问题 Given the following code: public class Main extends Application { private BorderPane rootLayout; private VBox toolbarLayout; private URL path; public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { FXMLLoader loader = new FXMLLoader(); // Root View path = getClass().getResource("mainLayout.fxml"); try { loader.setLocation(path); rootLayout = (BorderPane) loader.load(); } catch (IOException e){ System.out.println("Not found: " + path); e

Hide input caret of TextField in JavaFX8

陌路散爱 提交于 2019-12-28 06:59:14
问题 I would like to hide the input caret of a TextField in JavaFX8. I already tried to set the text fill to white (my TextField has a white background), but then my user input also disappears. The problem is that the textfield still needs focus, so I also thought of some EventHandler which listens to user input, and focusses on the textfield when a key is pressed, but then I would miss the first key typed. Anyone that knows how to do this? Or is it not possible in JavaFX8? 回答1: Update for Java

JavaFX: Weird ClassNotFoundException after updating to Java 9

感情迁移 提交于 2019-12-28 06:49:11
问题 I started a Maven project in Java 8 and wanted to migrate it to Java 9. At the same time I also went from Eclipse Neon EE to Eclipse Oxygen EE. (JFX SDK reinstalled). While the Eclipse Workspace shows no errors; as soon as I try to compile and run the exact same program that used to run perfectly fine in Java 8, I get the following Exception: {...} Caused by: java.lang.ClassNotFoundException: com.sun.javafx.css.converters.PaintConverter at java.base/jdk.internal.loader.BuiltinClassLoader

JavaFx Event argument type mismatch

一笑奈何 提交于 2019-12-28 06:46:52
问题 I using JavaFx for first time and I encountered a problem with events. I built a form with SceneBuilder and I add an event on .fxml and controller but it's always return with: Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: argument type mismatch FirstScene.fxml: <AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="background" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="examlog.gui

Set font in javafx

青春壹個敷衍的年華 提交于 2019-12-28 06:16:47
问题 How to set font to a column in table view in java fx. I have a table with 3 columns and i want to set different fonts for each of the columns. Also, is it possible to change the font in runtime. Please help with some sample code. 回答1: Changing the table column style: You should to use TableColumn#setCellFactory() to customize cell item rendering. For example, datamodel with like this Person class: // init code vs.. TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol

Set font in javafx

爷,独闯天下 提交于 2019-12-28 06:16:23
问题 How to set font to a column in table view in java fx. I have a table with 3 columns and i want to set different fonts for each of the columns. Also, is it possible to change the font in runtime. Please help with some sample code. 回答1: Changing the table column style: You should to use TableColumn#setCellFactory() to customize cell item rendering. For example, datamodel with like this Person class: // init code vs.. TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol

JavaFX on Linux is showing a “Graphics Device initialization failed for : es2, sw”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-28 05:56:35
问题 I've just started coding/testing JavaFX stuff on Linux and I'm facing an error at time to start a simple app. I found many people concerning about that in Foruns but I could find a clear explanation about the reasons why it happens. I'd like to understand what is missing in my scenario to get it working. Any suggestion will be really apreciated. Env info: java version "1.8.0-ea" Java(TM) SE Runtime Environment (build 1.8.0-ea-b123) Java HotSpot(TM) Client VM (build 25.0-b65, mixed mode) Linux

JavaFX: Why does stage.setResizable(false) cause additional margins?

ⅰ亾dé卋堺 提交于 2019-12-28 05:21:06
问题 This small JavaFX test application import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class ApplicationWithNonResizableStage extends Application { public static void main(final String[] args) { launch(args); } @Override public void start(final Stage primaryStage) throws Exception { final Rectangle rectangle = new Rectangle(200, 100,

JavaFX - setVisible doesn't “hide” the element

拜拜、爱过 提交于 2019-12-28 05:06:05
问题 In JavaFX, if I have a scene with 2 VBox elements and each VBox has multiple Label in it. If I set the top VBox to invisible , why does the bottom VBox not move up the scene where the top VBox was ? The VBox is invisible but I would expect the other objects to move into its place. I am using FXML to load my controls. 回答1: Node.setVisible(boolean) just toggles the visibility state of a Node . To exclude a Node from its parents layout calculations you additionally have to set its managed state,

How to get GridPane Row and Column IDs on Mouse Entered in each cell of Grid in JavaFX?

╄→尐↘猪︶ㄣ 提交于 2019-12-28 04:28:05
问题 I am trying out JFX Drag and Drop feature in my application (later connecting the objects in a sequence). I could not find any easy way to drag and drop my ImageView/Button at suitable position in my pane, hence I am planning to apply use of GridPane. The GridPane would be a large canvas with more than (50x50) cells. If I specify in my code that I need to drag and drop by ImageView at, let's say, (2,2) cell, I am able to do it. But, I need to give that access to my user. User could move the