我想在JavaFX中应用border-radius和shadow.
在CSS3中它将是:
box-shadow: rgba(0,0,0,0.8) 0 0 10px;
border-radius: 3px;
Run Code Online (Sandbox Code Playgroud)
现在我想在JavaFX中使用它,但即使是border-radius也不能在JavaFX Scene Builder中工作.这是我的问题的屏幕截图:
JavaFX截图http://rapid-img.de/images/b92e2112.jpg
在屏幕截图中,您可以看到我使用:
-fx-border-radius: 10 10 10 10;
-fx-background-radius: 10 10 10 10;
Run Code Online (Sandbox Code Playgroud) 我正在使用eclipse kepler和java SE 1.8 jdk系统库,但是当我使用任何javafx类或方法时,eclipse会发出类似的警告Access restriction: The type 'TableColumn<?,?>' is not API (restriction on required library 'C:\Program Files\Java\jdk1.8.0_05\jre\lib\ext\jfxrt.jar').
我已经尝试向系统库添加访问规则,以允许使用通配符访问库中的所有jar,*但警告仍然存在.我也使用maven建设项目.代码有效,但警告是唠叨,并且在我编码时影响可读性.任何帮助表示赞赏.
编辑:我也尝试@SuppressWarnings("restriction")在我的课程开头添加,但这仍然无法解决未知原因并隐藏我可能需要看到的所有其他限制警告
我在运行一个简单的hello world应用程序时遇到了一些问题.它抛出以下错误:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(LauncherImpl.java:182)
at com.sun.javafx.application.LauncherImpl$$Lambda$2/1329552164.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException: Error resolving onAction='#printHello', either the event handler is not in the Namespace or there is an error in the script.
/home/willi/java/IdeaProjects/JavaFXApp/out/production/JavaFXApp/sample/sample.fxml:23
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:104)
at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:606)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:766)
at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2827)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2536)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101)
at sample.Main.start(Main.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863) …Run Code Online (Sandbox Code Playgroud) 如何设置TableView中的"THIS"点?
我的CSS代码如下:
*/*
* Empty Stylesheet file.
*/
.root{
-fx-background-color: #262626;
}
.table-view{
-fx-background-color: transparent;
}
.table-view:focused{
-fx-background-color: transparent;
}
/* Spaltenköpfe
Struktur column-header-background -> column-header */
.table-view .column-header-background{
-fx-background-color: linear-gradient(#131313 0%, #424141 100%);
}
.table-view .column-header-background .label{
-fx-background-color: transparent;
-fx-text-fill: white;
}
.table-view .column-header {
-fx-background-color: transparent;
}
.table-view .table-cell{
-fx-text-fill: white;
}
.table-row-cell{
-fx-background-color: -fx-table-cell-border-color, #616161;
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0.0em; /* 0 */
}
.table-row-cell:odd{
-fx-background-color: -fx-table-cell-border-color, #424242;
-fx-background-insets: 0, 0 0 1 0; …Run Code Online (Sandbox Code Playgroud) 我有这段代码:
Alert alert =
new Alert(AlertType.WARNING,
"The format for dates is year.month.day. " +
"For example, today is " + todayToString() + ".",
ButtonType.OK,
ButtonType.CANCEL);
alert.setTitle("Date format warning");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
formatGotIt = true;
}
Run Code Online (Sandbox Code Playgroud)
在上面,我要求两个标题为"是"和"否"的按钮.但是,我希望改变它们.
有关Java Oracle社区的问题(https://community.oracle.com/thread/3934986)
问题:
我已经设置了下面的代码Button,它的全名表示文件路径.所以当它Button被拖动到文件夹或桌面时(让我们说Windows),它会被用户的操作系统复制.
我想获取已完成放置的目标文件夹.
码:
button.setOnDragDetected(event -> {
/* allow copy transfer mode */
Dragboard db = startDragAndDrop(TransferMode.COPY,TransferMode.LINK);
/* put a string on dragboard */
ClipboardContent content = new ClipboardContent();
/*Adding a file into the ClipboardContent*/
content.putFiles(Arrays.asList(new File(getSongPath())));
........//not showing this code....
db.setContent(content);
event.consume();
}
Run Code Online (Sandbox Code Playgroud)
编辑:(29/09/2016)
下降完成后:
setOnDragDone(d -> {
System.out.println(
"Drag Done,is drop completed?" + d.isDropCompleted() + " , is accepted?" + d.isAccepted());
System.out.println("Accepted Mode:" + d.getAcceptedTransferMode());
System.out.println(" Target:" + …Run Code Online (Sandbox Code Playgroud) JavaFX从Windows剪贴板获取图像的默认方式,
Clipboard.getSystemClipboard().getImage();
Run Code Online (Sandbox Code Playgroud)
,似乎已损坏。
图像的透明度似乎出了点问题。设置在黑色背景上,图像看起来不错,但是设置在白色背景上,什么也没有显示。
您可以使用以下最小,完整,可验证的示例测试剪贴板。
环境:Windows 7,Java 8更新202
下面,我将描述我已经知道的事情。
然而,没有人成为问题的核心或得到答案。
我似乎在Java错误数据库中找不到与此问题有关的错误。
在AWT剪贴板上不会出现图像问题,但是我想要一个使用JavaFX剪贴板的解决方案。
我知道Windows剪贴板包含同一事物的多个版本,只是格式不同。使用InsideClipboard或Free Clipboard Viewer可以很容易地看到它。
JavaFX Clipboard可以识别某些格式。有时,它们的名称不同。application/x-java-rawimage是Java认为的图像;在代码中,您将此称为DataFormat.IMAGE。
我怀疑DIBWindows中的剪贴板格式与Java的格式匹配application/x-java-rawimage,但是在源代码中找不到这种格式的证明。
对于将图像复制到剪贴板的各种应用程序,JavaFX似乎也存在相同的透明性问题:
嘿,我在网上搜索了一段时间,但我找不到解决以下问题的方法:
在javafx中你有3个基本文件; controller-class,fxml文件和应用程序类.现在我想在控制器中做出反应点击按钮(效果非常好)并更改该点击的屏幕(你通常使用stage.setScreen()),但我没有参考舞台(你可以在应用程序类中找到).
应用程序示例:
public class JavaFXApplication4 extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* @param args the command line arguments
*/ …Run Code Online (Sandbox Code Playgroud) 是否有任何免费的,可立即使用的CSS主题来定制JavaFX应用程序的整体外观,如默认的modena.css?
很高兴在这里收集可用样式表的列表.