为什么
ZonedDateTime now = ZonedDateTime.now();
System.out.println(now.withZoneSameInstant(ZoneOffset.UTC)
.equals(now.withZoneSameInstant(ZoneId.of("UTC"))));
Run Code Online (Sandbox Code Playgroud)
打印出来false
?
我希望这两个ZonedDateTime
实例是平等的.
如何从当前日期减少一个月,并希望java.util.Date
使用此代码在变量im中疼痛,但它在第二行显示错误
java.util.Date da = new Date();
da.add(Calendar.MONTH, -1); //error
Run Code Online (Sandbox Code Playgroud)
如何将这个日期存储在java.util.Date
变量中?
我正在研究JavaFX项目.我需要在JavaFX上执行一些任务TextField
.
例如,TextField
我要打印的"焦点上"事件
System.out.println("Textfield on focus");
Run Code Online (Sandbox Code Playgroud)
它应该打印出"焦点"事件
System.out.println("Textfield out focus");
Run Code Online (Sandbox Code Playgroud) 我想在表单的resize事件(Scene
或者Stage
不管它是什么)上执行一些功能.
但是如何在JavaFX中检测表单的resize事件?
如何在MATLAB编辑器中重新格式化代码?其他IDE通常具有重新格式化或格式化选项,用于排列书面代码的位置.MATLAB的编辑有吗?我使用MATLAB R2013a
我对JavaFX有一个奇怪的问题.我Scene
在SceneBuilder中设计了一个简单的东西.文本在预览中看起来没问题,但在运行应用程序时文本看起来模糊,请考虑以下图像.
这是
FXML
:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<AnchorPane id="AnchorPane" fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="br.mviccari.javafxtest.controllers.TelaMensagemController">
<children>
<TitledPane alignment="CENTER_LEFT" animated="false" collapsible="false" contentDisplay="LEFT" prefHeight="400.0" prefWidth="600.0" text="Janela legal" textAlignment="LEFT" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<HBox id="HBox" alignment="CENTER" spacing="5.0" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0">
<children>
<Button mnemonicParsing="false" onAction="#acaoFodase" prefHeight="53.9609375" prefWidth="128.0" text="Foda-se" />
<Button mnemonicParsing="false" onAction="#acaoOk" prefHeight="53.9609375" prefWidth="128.0" text="OK" />
</children>
</HBox>
<TextArea fx:id="campoTexto" disable="false" …
Run Code Online (Sandbox Code Playgroud) 我想在WebView
我的JavaFX应用程序中加载HTML 文件.该文件位于我的项目目录中,webviewsample
包内.
我使用了以下代码:
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("WebView test");
WebView browser = new WebView();
WebEngine engine = browser.getEngine();
String url = WebViewSample.class.getResource("/map.html").toExternalForm();
engine.load(url);
StackPane sp = new StackPane();
sp.getChildren().add(browser);
Scene root = new Scene(sp);
primaryStage.setScene(root);
primaryStage.show();
}
Run Code Online (Sandbox Code Playgroud)
但它抛出一个例外说:
Application start方法java.lang.reflect.InvocationTargetException中的异常
如何为扩展JavaFX对象的类设置CSS样式?
public class DiagramPane extends ScrollPane implements IDiagramEditor {
// .... Methods go here
}
Run Code Online (Sandbox Code Playgroud)
我在main方法中尝试了以下方法:
public class DiagramPane extends ScrollPane implements IDiagramEditor {
DiagramPane() {
this.setStyle("-fx-background-color: #f8ecc2;-fx-font-size: 8pt;");
setStyle("-fx-background-color: #f8ecc2;-fx-font-size: 8pt;");
}
}
Run Code Online (Sandbox Code Playgroud) 如何AnchorPane
使用Scene Builder 将背景图像添加到a ?
我试过它:
-fx-background-image url('C:/Users/Documents/page_background.gif')
Run Code Online (Sandbox Code Playgroud)
我如何在Scene Builder中设置它.
并生成的FXML:
<AnchorPane id="LoginAnchorPane" fx:id="LoginAnchorPane" prefHeight="400.0" prefWidth="600.0" style="-fx-background-image: url('C:/Users/Documents/page_background.gif');" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafx_lsdu.LoginController">
Run Code Online (Sandbox Code Playgroud)