5

I have the following dialog: enter image description here

The last line shows only part of the text - the text is cut and instead of text "..." is shown. How can I make the dialog show all text?
EDIT 1
This is the code

Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Выход из программы");
alert.setHeaderText("Вы действительно хотите выйти из программы?");
alert.setContentText("Нажмите ОК для выхода. Для продолжения работы с программой нажмите Отмена.");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){

} else {

}


EDIT 2 This problem appears only in linux (centos 7.1 and gnome 3). In windows 7 all the text is shown at two lines and everything is ok.

EDIT 3
I think it's linked with the height of the dialog window. As When I alert.setResizable(true) and increase the height of the window the second line appears.

Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
  • 1
    In order to *allow* people to help you, you should always post some code accompanying your question. Please add the relevant code of yours or at least snippets with the relevant parts. – dot_Sp0T Jun 04 '15 at 11:57
  • @dot_Sp0T You are right. See edit 1. –  Jun 04 '15 at 12:03

1 Answers1

6

I didn't dig deeper for the reason, but alternatively you can set inner dialog pane's content instead:

alert.getDialogPane().setContent( new Label("твое содержание текста"));

Edit:

Maybe you know how to change the text of the Cancel button?

you can lookup the "Cancel" button from dialog pane:

Button cancelButton = ( Button ) alert.getDialogPane().lookupButton( ButtonType.CANCEL );
cancelButton.setText("Oтмена");
Uluk Biy
  • 48,655
  • 13
  • 146
  • 153
  • Thank you. It worked. Maybe you know how to change the text of the Cancel button? The problem is I can't find way to get the reference to this bundle. –  Jun 04 '15 at 12:39
  • @iJava, follow [this](http://stackoverflow.com/a/30215178) and [this](http://stackoverflow.com/a/25794018). – Uluk Biy Jun 04 '15 at 12:49
  • @iJava alternatively you may build your own buttons and put via createButtonBar(). Refer to Alert javadoc. – Uluk Biy Jun 04 '15 at 12:51
  • Thank you for help. Looking for node via lookup seems to be a better solution for my case. The problem is how to find out the css if of the button :) I tried the ".cancel-button", however it returns null. –  Jun 04 '15 at 12:56
  • Thank you. I did it. ButtonBar buttonBar=(ButtonBar) alert.getDialogPane().lookup( ".button-bar" ); Button button=(Button) buttonBar.getButtons().get(0); I think there is no another way to get css id - http://hg.openjdk.java.net/openjfx/8u40/rt/file/6cc08ec1ea82/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css –  Jun 04 '15 at 13:03
  • @iJava, actually dialogpane provides access its default buttons in its buttonBar. Get alert.getDialogPane().getButtonTypes() obseravlelist and traverse it, and get the ButtonType with ButtonData.CANCEL_CLOSE. – Uluk Biy Jun 04 '15 at 13:12
  • Imo its more safer. And you may accept the answer if it is **an** answer. – Uluk Biy Jun 04 '15 at 13:13
  • Can you show the example how to get reference to button via ButtonData.CANCEL_CLOSE? –  Jun 04 '15 at 13:48
  • Thank you very much! This is what I was looking for! –  Jun 04 '15 at 14:17