Tag: javafx

IntelliJ不了解Java9-ea上的java库

我正在使用jdk9-ea 149并创建了一个示例javafx应用程序 IntelliJ不理解java库,它以红色显示所有import语句,并且它们都是灰色的 。对于java.util.List,java.util.ArrayList它有相同的问题。 我能够在外面编译表单,但我无法从IntelliJ 2016.3.2 Ultimate Edition编译代码。 看起来我们需要向IntelliJ项目添加一些库,但是使用java9 build 149 jigsaw我不知道该怎么做。 我正在使用实验function仍然无法理解import语句 – 请参阅下面的intellij设置 IntelliJ版本: IntelliJ 2016.3.2 Ultimate Edition Java版本:java 9-ea build:149

如何在JavaFX中获取舞台的关闭事件?

在JavaFX中,如果用户单击某个阶段的关闭按钮(X)(最右上角),我该如何获取该事件? 我希望我的应用程序在窗口关闭时打印调试消息。 ( System.out.println(“Application Close by click to Close Button(X)”) ) @Override public void start(Stage primaryStage) { StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle(“Hello World!”); primaryStage.setScene(scene); primaryStage.show(); // Any Event Handler //{ System.out.println(“Application(primaryStage) Closed by click to Close Button(X)”); //} }

如何在JavaFX中以编程方式切换选项卡

一次只能看到一个选项卡。 用户使用鼠标/键盘选择一个。 假设,TabPane上有三个选项卡,首先是一个按钮。 当用户按下按钮时,我想要打开第二个标签。 然后必须有一些代码切换到绑定到按钮的第二个Tab。 有可能以编程方式吗? 如果是这样,怎么样?

复制ObservableList java

我有一个MasterData,它是一个ObservableList和filteredData,它也是一个ObservableList。 然后,我想用它来设置filter时显示过滤后的数据 ,但也可以在必要时恢复 ,这里是MCVE: package br; import javafx.collections.FXCollections; import javafx.collections.ObservableList; public class Main{ private static ObservableList masterData = FXCollections.observableArrayList(); private static ObservableList filteredData = FXCollections.observableArrayList(); static Filter filter = new Filter(); public static void addDummy(){ masterData.add(new Foo(“a”,1)); masterData.add(new Foo(“aa”,3)); masterData.add(new Foo(“b”,2)); masterData.add(new Foo(“bb”,4)); masterData.add(new Foo(“c”,3)); } public static void printData(ObservableList list){ for(Foo f: list) System.out.println(f.getName()); […]

JavaFX TabPane:如何监听选择更改

当用户从一个选项卡转到另一个选项卡时,我想做一些操作,因为我用Scene Builder进行了表单设计我不能使用这里提到的代码(他使用了TabPaneBuilder类) 我猜这个代码可以工作,但它不会对选项卡选择更改做出反应。 @FXML protected TabPane chatTabs; . . . chatTabs.selectionModelProperty().addListener( new ChangeListener<SingleSelectionModel> { @Override public void changed(ObservableValue<? extends SingleSelectionModel> ov, SingleSelectionModel t, SingleSelectionModel t1) { System.err.println(“changed”); } } } );

Root尚未设置Java 8 Eclipse的错误

最近我为我的JavaFX应用程序安装了Java 8 build 124,我开始收到这些错误: javafx.fxml.LoadException: Root hasn’t been set. Use method setRoot() before load. /Users/jonathan/Projects/Dominion/target/classes/dominion/application/controller/main_overview_tab.fxml:13 at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2613) at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:104) at javafx.fxml.FXMLLoader$RootElement.constructValue(FXMLLoader.java:1320) at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740) at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2723) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) at dominion.application.controller.MainOverviewTab.initView(MainOverviewTab.java:64) at dominion.application.controller.MainOverviewTab.initializeController(MainOverviewTab.java:55) at dominion.application.controller.GameSetupController.(GameSetupController.java:37) at dominion.application.controller.DashboardController.(DashboardController.java:40) at dominion.application.controller.MainController.(MainController.java:37) at dominion.application.Dominion.start(Dominion.java:18) at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837) at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335) at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301) at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298) at java.security.AccessController.doPrivileged(Native Method) at […]

JavaFX透明窗口仅接收绘制像素上的鼠标事件

我想要一个与屏幕大小相同的舞台,它是完全透明的,可以在任何地方接收鼠标事件。 在下面的示例中,仅当鼠标位于圆圈上时才会收到鼠标事件。 我在使用Java 8u11的Windows XP和Windows 7上都看到了这个问题 import javafx.application.Application; import javafx.geometry.Rectangle2D; import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.StageStyle; public class TransparentTest extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage ignored) throws Exception { Stage stage = new Stage(StageStyle.TRANSPARENT); stage.setTitle(“Transparent app […]

javafx将按钮添加到网格窗格

我正在动态添加按钮到网格窗格,但在给它们function后,它们都显示相同的function,我不知道为什么? import java.awt.Panel; import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Button; import javafx.scene.layout.GridPane; public class TestController implements Initializable { @FXML Panel mpanel; @FXML GridPane gpnael; int x=0,y=0,i=0,y1=0; /** * Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { // TODO } @FXML private void add(ActionEvent […]

Javafx:检测对tableView所做的所有更改,包括在任何表行上添加/删除表行和单元格编辑

鉴于我有一个tableView ,如何跟踪所有更改,即添加/删除新行, 其中一个表格单元的值已更改 ,并在检测到任何这些更改时触发相同的事件? 目前,我在下面有以下代码,如果我添加一行,它只会设法检测更改。 当我编辑任何行的表格单元格时以及删除行时 ,它无法检测到更改。 ObservableList observableListOfTrades =FXCollections.observableArrayList(); observableListOfTrades.add(newTrade); fxTransactionLog.getItems().add(observableListOfTrades.get(observableListOfTrades.size()-1)); observableListOfTrades.addListener(new ListChangeListener() { @Override public void onChanged(ListChangeListener.Change change) { System.out.println(“Detected a change! “); } }); 根据要求,我发布了我的Trade等级 public class Trade{ // properties private ObjectProperty transactionDate; private StringProperty itemName; private StringProperty buySell; private DoubleProperty volume; private DoubleProperty price; private DoubleBinding transactionFee; public Trade(BuySell buySell, LocalDate […]

Javafx在全屏时调整组件大小

原始尺寸截图 全屏截图 当我resize时,我如何很好地安排组件。 即时通讯使用FXML进行GUI FXML代码