JDK-8015085 : [macosx] Label shortening via " ... " broken when String contains combining diaeresis
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7,7u21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2013-04-22
  • Updated: 2015-09-29
  • Resolved: 2015-02-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b52Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version  " 1.7.0_21 " 
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin Macintosh-7.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
When a JLabel does not fit into the allotted space, the String it contains is automatically shortened by truncating the String and appending an ellipsis character ( " ... " ). This works beautifully for regular Strings.
But as soon as the String contains a combining diaeresis, e.g. to turn a 'u' into a '?', the way Strings are shortened changes. The String is not truncated anymore after the last character that still fits into the available space, but at the last character that still fits AND is a punctuation or whitespace character. This looks odd especially when a JTable lists URLs, of which only some contain a diaeresis.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See source code for reproduction.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JLabels with and without diaeresis should be shortened exactly the same way.
ACTUAL -
JLabels with diaeresis are shortened differently than the one with.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

/**
 * Shortening via  " ... "  is broken for Strings containing a combining diaeresis.
 */
public class TestBadBreak {

    public static void main(String[] args) {
        final DefaultTableModel model = new DefaultTableModel(new Object[]{ " With " ,  " Without " }, 2);
        final String stringWithCombiningDiaeresis =  " http://withCombiningDiaeresis.aaaaaaaaa.com/a\u0308aaaaaaaaaaaa/ aaaaaaaaaaaaaa/aaaaaaaaaaaa/ " ;
        final String stringWithoutCombiningDiaeresis =  " http://withoutCombiningDiaeresis.aaaaaaaaa.com/\u00E4aaaaaaaaaaaa/ aaaaaaaaaaaaaa/aaaaaaaaaaaa/ " ;
        model.setValueAt(stringWithCombiningDiaeresis, 0, 0);
        model.setValueAt(stringWithoutCombiningDiaeresis, 0, 1);
        final JTable table = new JTable();
        table.setModel(model);
        final JFrame frame = new JFrame();
        frame.getContentPane().add(new JScrollPane(table));
        frame.setBounds(200, 200, 300, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                frame.setVisible(true);
            }
        });
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
One can use the java.text.Normalizer to remove diaeresis.
Comments
The same issue is reproduced in Apple JDK 6 (build 1.6.0_29-b11-397-11G63)
26-09-2013

Alexander, what is effort scope (in b.days) to implement it? Further we will consider to defer or fix.
19-09-2013

Bug is visible to user.
19-09-2013