Question

In my application, I have a 2-column org.jdesktop.swingx.JXTable. Both columns contain String data. One column uses the default cell editor (org.jdesktop.swingx.JXTable.GenericEditor) and the other uses a custom cell editor (CustomCellEditor.java).

With the Windows L&F both of the cells are rendered the same; however, with the GTK L&F there's a slight difference which causes the text to be obscured. What property needs to be set to render the custom editor properly on GTK?

private class CustomCellEditor extends DefaultCellEditor
{
    public CustomCellEditor(int maxStringLength)
    {
        super(new JTextField()

        ((JTextField) editorComponent).setDocument(new CustomDocument(maxStringLength));
    }

    class CustomDocument extends PlainDocument
    {
        private int limit;

        public CustomDocument(int limit)
        {
            super();
            this.limit = limit;
        }

        @Override
        public void insertString(int offset, String str, AttributeSet attr)
            throws BadLocationException
        {
          //...
        }
    }
}

Default on Windows:

enter image description here

Custom on Windows:

enter image description here

Default on Ubuntu:

enter image description here

Custom on Ubuntu:

enter image description here

Was it helpful?

Solution

I have the same issue in the past but with Nimbus L&F My issue

Solved by doing this

JTextField#setBorder( null )

In your code

public CustomCellEditor(int maxStringLength)
    {
        super(new JTextField());
        ((JTextField) editorComponent).setDocument(new CustomDocument(maxStringLength));
        ((JTextField) editorComponent).setBorder(null); // cast may be not needed
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top