I need to know when the text for a JButton is truncated by the layout. So, in order to find out I am overriding the following method in our custom ButtonUI delegate:
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
//the text argument will show an ellipse (...) when truncated
}
Inside the method I check to see if the text argument ends with an ellipse.
Is there a better way for me to check if the text is truncated? What about the ellipse? Is that the universal symbol for truncated text, or do I need to look for localized symbols that will demarcate truncated text?
I noticed that OSX will use a single character representing the ellipse and Windows will use three periods. I assume this is based on the font being used, but it got me thinking of other things that may sneak up on me.
Thanks.