1

I have an FX application that allows you to select some variables. When a variable is selected, the text of the application bar/title bar is replaced with the variable description.

Some descriptions are too long though and the text gets cut off. Is there a way to have the application bar or title bar wrap the description to a new line? Or is there a way to add a tool tip to the application bar? Or is there a more elegant and user friendly way to display the variable description?

I am leaning toward creating my own title bar based on this post: Custom title bar in Javafx 2.0?

I am hoping creating my own allows me to set a vertical size that can allow two lines.

Community
  • 1
  • 1
Seephor
  • 1,692
  • 3
  • 28
  • 50

1 Answers1

0

You can use a Label which is positioned somewhere in the layout.Then you can use the method below:

     /**
     * Returns the given String with a fixed number of letters
     * 
     * @param string
     * @param letters
     * @return A String with the given length followed by ...
     */
    public static String getMinString(String string, int letters) {
        if (string.length() < letters)
            return string;
        else
            return string.substring(0, letters) + "...";
    }

So every time the text is bigger you define a size(for example 15 characters) and you modify the text of the Label,calling this method which returns a smaller String.

Actually using a Label will automatically do the above,but in case you want to use something other i have added it.

The user can see the whole variable through the ToolTip of the Label

GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93