zoukankan      html  css  js  c++  java
  • JavaFX引入资源问题

    描述
    - 使用javafx 引入资源的时候 抛出异常 在swing引入资源 采取相对路径即可,而javafx不是

        ImageView imageNode = (ImageView) root.lookup("#myimage");
        imageNode.setImage(new Image("resouces/标题画面.jpg"));
    • image 路径下 查看源代码发现是
     private static String validateUrl(final String url) {
            if (url == null) {
                throw new NullPointerException("URL must not be null");
            }
    
            if (url.trim().isEmpty()) {
                throw new IllegalArgumentException("URL must not be empty");
            }
    
            try {
                if (!URL_QUICKMATCH.matcher(url).matches()) {
                    final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
                    URL resource;
                    if (url.charAt(0) == '/') {
                        resource = contextClassLoader.getResource(url.substring(1));
                    } else {
                        resource = contextClassLoader.getResource(url);
                    }
                    if (resource == null) {
                        throw new IllegalArgumentException("Invalid URL or resource not found");
                    }
                    return resource.toString();
                }
                // Use URL constructor for validation
                return new URL(url).toString();
    • 原来是classloder下载入的,那么我们只需要从bin下导入文件即可

    Paste_Image.png

  • 相关阅读:
    本地数据存储
    网络统计公式
    网络统计图形
    上海证券综合指数统计分析及挖掘(二)
    上海证券综合指数统计分析及挖掘(一)
    概论
    寿险精算学目录
    JavaScript脚本代码练习
    JavaScript脚本语言基础(一)
    层叠样式表(CSS)
  • 原文地址:https://www.cnblogs.com/dgwblog/p/7635199.html
Copyright © 2011-2022 走看看