相关疑难解决方法(0)

在IntelliJ for Maven项目中添加资源

我有这样的项目结构:

src
 |-main
    |-java
       |-com.abc.xyz
          |-Login.java
Run Code Online (Sandbox Code Playgroud)

我必须向此添加资源文件并使用以下方式读取资源

InputStream is = getClass().getResourceAsStream("launchers.properties");
Run Code Online (Sandbox Code Playgroud)

这是空的.

在Intellij中,我无法在文件夹下添加新包src/main,resources因此项目结构如下所示.如何将launchers.properties资源文件加载到项目中?

src
 |-main
    |-java
       |-com.abc.xyz
          |-Login.java
    |-resources
       |-com.abc.xyz
          |-Login
             |-launcher.properties
Run Code Online (Sandbox Code Playgroud)

我尝试了@maba建议的解决方案,但仍然无法正常工作

java intellij-idea maven

41
推荐指数
1
解决办法
8万
查看次数

如何设置Dialog控件Java FX/Java 8的图标

我可能会遗漏一些非常明显的东西,但我无法找到如何为Dialog组件设置Icon(更准确的是ProgressDialog).我知道如何为舞台做这件事,__CODE__但我没有为Dialog家族找到任何东西.不知何故,设置舞台图标不会影响对话框图标.

谢谢

java icons javafx javafx-8

17
推荐指数
3
解决办法
2万
查看次数

在对话框的左侧设置图像

我为JavaFX8u40的JavaFX警报对话框创建了这个非常简单的示例.

public class MainApp extends Application
{
    public static void main(String[] args)
    {
        Application.launch(args);
    }

    private Stage stage;

    @Override
    public void start(Stage primaryStage) throws Exception
    {
        Button create = new Button("Create Alert");
        create.setTooltip(new Tooltip("Create an Alert Dialog"));
        create.setOnAction(e ->
        {
            createAlert();
        });

        primaryStage.setScene(new Scene(create));
        primaryStage.show();

        stage = primaryStage;
    }

    protected Alert createAlert()
    {
        Alert alert = new Alert(AlertType.WARNING);
        Image image1 = new Image("http://www.mcaprojecttraining.com/images/java-big-icon.png");

        ImageView imageView = new ImageView(image1);

        alert.setGraphic(imageView);
        alert.initModality(Modality.APPLICATION_MODAL);
        alert.initOwner(stage);
        alert.getDialogPane().setContentText("Some text");

        alert.showAndWait()
            .filter(response -> response == ButtonType.OK)
            .ifPresent(response …
Run Code Online (Sandbox Code Playgroud)

javafx javafx-2 javafx-8

5
推荐指数
1
解决办法
3376
查看次数

标签 统计

java ×2

javafx ×2

javafx-8 ×2

icons ×1

intellij-idea ×1

javafx-2 ×1

maven ×1