JavaFX 8 Localization of dialog's internal elements

I am currently developing a JavaFX application with Slovak language localization and inside the application I am using an Alert dialog for showing exceptions with expandable content pane as shown below on images:

隐藏详细信息 - 提醒屏幕

I would like to have this dialog completely translated which is going well with Header , Title or Content but I cannot find a way how to translate the Show/Hide details label of the expandable area.

So my question can be a little bit generalized: How to change/translate text of JavaFX internal elements?

Thanks in advance for any help.

PS: For creation of this Alert dialog for exceptions I am using code as found on code.makery.ch


For your particular use case, you can add another listener to expandedProperty which will override the texts shown of "details button":

Platform.runLater(() ->
{
    Hyperlink detailsButton = ( Hyperlink ) alert.getDialogPane().lookup( ".details-button" );

    alert.getDialogPane().expandedProperty().addListener(
            ( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue ) ->
    {
        detailsButton.setText( newValue ? "My less text" : "My more text" );
    });

    // trigger listeners
    alert.getDialogPane().setExpanded( true );
    alert.getDialogPane().setExpanded( false );
});

For more common hack see Localizing JavaFx Controls. From there you need to put the following keys to your custom properties file:

// translate these
Dialog.detail.button.more = Show Details
Dialog.detail.button.less = Hide Details
链接地址: http://www.djcxy.com/p/26126.html

上一篇: 按下向下箭头时隐藏键盘

下一篇: JavaFX 8对话框内部元素的本地化