javafx

javafx启动第二个窗体

我的梦境 提交于 2020-08-11 01:04:29
特别要注意第二窗体对应的view的fxml文件路径写法(view和controller都放在各自的包下): @FXML protected void show2Action() throws IOException { Stage stage = new Stage(); stage.setTitle("第二个窗体实验"); AnchorPane pane = FXMLLoader.load(getClass().getResource("../javafxcontroller2.fxml"));//要注意fxml文件的类路径写法(与本JavaFXController.java的相对关系) Scene scene = new Scene(pane,300,400); stage.setScene(scene); stage.initModality(Modality.APPLICATION_MODAL);//模式窗体 stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { System.out.println("window close event"); if(i++<2){ event.consume(); // i=0;

拖动StageStyle.UNDECORATED的窗体

北慕城南 提交于 2020-08-11 00:56:57
在JavaFX中,可以通过在窗体的边框上点击鼠标(不松开)进行拖动,但是当窗体设置为“StageStyle.UNDECORATED”,没有边框,或者在窗体的scene中拖动窗体该如何操作呢? 可以供过在窗体中对scene的“setOnMousePressed”和“setOnMouseDragged”事件重写,处理鼠标事件,拖动窗体。具体示例代码如下: package ch04; /** * @package ch04 * @date 2020/5/5 * @author qiaowei * @version 1.0 * @description */ import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.input.MouseEvent; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.stage.StageStyle; public class DraggingStage extends Application {

Handling CSS errors in Javafx

痞子三分冷 提交于 2020-08-09 12:31:06
问题 I am writing a JavaFX program, where the user enters a color's Hex value and its set as a background color of StakePane. The code is: stakePane.styleProperty().setValue("-fx-background-color: "+inputValue+";"); It works fine for a valid Hex value input.But when the user enters invalid Hex value its gives the following error on console: javafx.scene.CssStyleHelper calculateValue WARNING: Could not resolve '#E91E63g' while resolving lookups for '-fx-background-color' from inline style on

如何在Mac上安装Java 8

て烟熏妆下的殇ゞ 提交于 2020-08-08 14:20:24
问题: I want to do some programming with the latest JavaFX, which requires Java 8. I'm using IntelliJ 13 CE and Mac OS X 9 Mavericks. 我想使用需要Java 8的最新JavaFX进行一些编程。我正在使用IntelliJ 13 CE和Mac OS X 9 Mavericks。 I ran Oracle's Java 8 installer, and the files look like they ended up at 我运行了Oracle的Java 8安装程序,文件看起来像最终在 /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk but previous versions are at 但以前的版本在 /System/Library/Java/JavaFrameworks/jdk1.6.... Not sure why the latest installer puts this in /Library instead of /System/Library (nor what the difference is). 不知道为什么最新的安装程序会将它放在 /Library 而不是 /System

无责任书评:每个Java程序员都应该深入理解Java虚拟机

落爺英雄遲暮 提交于 2020-08-08 13:50:13
Java这门语言的发展是很有意思的,它不像Python, Ruby 等完全是开源社区驱动,也不像C#,VB.NET主要由微软操刀。它是一个以Oracle(之前是Sun)为主,各大巨头一起参与,一起制定标准的一门语言。 想对Java添加一点特性, 得走JCP流程,巨头们要审查,看看对自己是否有利,然后投票决定。 在Java的生态中, 官方曾经制定了很多技术和标准,什么Applet, JSP, EJB,JSF, JavaFX...... 但是大部分都被淘汰了,原因很简单,这些标准制定的周期很长, 难以跟上软件行业迅速的变化,等到各大厂商再把实现给搞定,黄花菜都凉了。 所以大家最常用的反而是开源的框架和工具如Spring。 但是Java 语言本身和Java虚拟机是个例外,因为他们不需要也不可能像应用层那样剧烈变化,所以作为后端程序员,对他们进行“投资”是最划算的。 所以我们今天就来聊聊Java虚拟机的书籍。写这方面的书很多, 比如我最早看的就是这一本。 我个人认为这是相当不错的一本书,它在讲ClassLoader 的时候举了一个例子,如果没有双亲委托模型,不怀好意的那些java class 很容易会破坏你的系统,这个例子让我印象如此深刻,以至于我在写《我是一个Java Class》的时候,也编了一个类似的例子。 这本书还花了大量的篇幅讲解Java Class的文件格式,整数运算

How do I fix JavaFX runtime components are missing?

拜拜、爱过 提交于 2020-08-07 05:19:45
问题 I have the following installed on Ubuntu 18.04.1 LTS: openjdk version "10.0.2" 2018-07-17 OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1) OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1, mixed mode) javafx.runtime.version=8.0.161 javafx.runtime.build=b00 However I try to run the sample java application that uses javafx I get the following error: $ java -jar Untitled.jar Error: JavaFX runtime components are missing, and are required to run this

How do I fix JavaFX runtime components are missing?

六眼飞鱼酱① 提交于 2020-08-07 05:19:25
问题 I have the following installed on Ubuntu 18.04.1 LTS: openjdk version "10.0.2" 2018-07-17 OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1) OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1, mixed mode) javafx.runtime.version=8.0.161 javafx.runtime.build=b00 However I try to run the sample java application that uses javafx I get the following error: $ java -jar Untitled.jar Error: JavaFX runtime components are missing, and are required to run this

How do I fix JavaFX runtime components are missing?

天大地大妈咪最大 提交于 2020-08-07 05:18:05
问题 I have the following installed on Ubuntu 18.04.1 LTS: openjdk version "10.0.2" 2018-07-17 OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1) OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1, mixed mode) javafx.runtime.version=8.0.161 javafx.runtime.build=b00 However I try to run the sample java application that uses javafx I get the following error: $ java -jar Untitled.jar Error: JavaFX runtime components are missing, and are required to run this

自己编译JavaFX Scene Builder

这一生的挚爱 提交于 2020-08-05 08:50:28
虽然没有捣鼓JAVAFX,但是 近日发现Oracle官网竟然不提供JAVAFX Scene Builder的下载的。原先发布的2.0版本提示过期,心中一怒。几番寻找发现Scene Builder被迁至OpenJFX中。不知为什么官方不给编译Scene Builder.不管它。 我们首先需要同步OpenJFX源码: hg clone http://hg.openjdk.java.net/openjfx/8u-dev/rt 我们可以使用TorToisHG来进行同步。 同步源码之后,我们可以发现apps/scenebuilder这个目录。哈哈,这就是Scene Builder的源码目录。 然后我们打开NetBeans导入SceneBuilderApp,SceneBuilderkit这两个项目。(SceneBuilderApp依赖于SceneBuilderkit项目) 在NetBeans下构建SceneBuilderApp项目即可。之后再dis/下可以找到SceneBuilderApp.jar和lib/SceneBuilderkit.jar这就是我们需要的。 我们可以将他们拷贝出来。编写个bat运行 start %JAVA8_HOME%\bin\javaw -jar SceneBuilderApp.jar 到此结束。 目前最新版为2.0.1 注意几点: 1.通过JAVA8启动 2

The module name specified in 'application.mainModule' (null) has not the expected value (hellofx) [closed]

折月煮酒 提交于 2020-08-03 11:31:48
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 days ago . Improve this question Running the JavaFX project with the run function in Gradle works fine, but using the jpackage function in Gradle does not work properly. An error occurs while executing the jpackage function: 12:56:41 AM: Executing task 'jpackage'... > Configure project : Project : => 'hellofx'