Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JTable] text shifts up when start editing and rowHeight is odd #126

Open
vlsi opened this issue Mar 30, 2020 · 10 comments
Open

[JTable] text shifts up when start editing and rowHeight is odd #126

vlsi opened this issue Mar 30, 2020 · 10 comments
Labels
bug Something isn't working

Comments

@vlsi
Copy link
Contributor

vlsi commented Mar 30, 2020

Test case:

  1. Add the following to TableDemo

    // Ensure row height is not divisible by 2
    table.setRowHeight(table.getRowHeight() | 1);
  2. Try editing the cells

Actual results: text in editable fields moves up by 1px or so.

Just in case you wonder: JMeter adjusts rowHeight based on the font size and zoom level. At certain zoom levels the computed rowHeight becomes odd.

@weisJ weisJ added the bug Something isn't working label Mar 30, 2020
@weisJ
Copy link
Owner

weisJ commented Mar 30, 2020

Does this happen with the default font size or only a specific one? I'm not getting this behaviour in windows with the default size.
You may also try to remove #patchMacOsFonts to see is related to the system font.

@vlsi
Copy link
Contributor Author

vlsi commented Mar 30, 2020

This happens with the default font in macOS.

@vlsi
Copy link
Contributor Author

vlsi commented Mar 30, 2020

You may also try to remove #patchMacOsFonts to see is related to the system font.

I've removed patchMacOsFonts and the issue is still there.

@weisJ
Copy link
Owner

weisJ commented Mar 30, 2020

What baseline does the macOS system font have for standard text characters i.e.
what does Font#getBaselineFor return?

@vlsi
Copy link
Contributor Author

vlsi commented Mar 30, 2020

font.getBaselineFor('a') = 0 javax.swing.plaf.FontUIResource[family=Lucida Grande,name=Lucida Grande,style=plain,size=12]
font.getBaselineFor('a') = 0 javax.swing.plaf.FontUIResource[family=Dialog,name=Dialog,style=plain,size=12]

@weisJ
Copy link
Owner

weisJ commented Mar 30, 2020

How about the font height? I suspect that the issue is that the font is generally shifted in textfields with odd height.

@vlsi
Copy link
Contributor Author

vlsi commented Mar 30, 2020

Font f = defaults.getFont("Table.font");
System.out.println("f = " + f);
System.out.println("font.getBaselineFor('a') = " + f.getBaselineFor('a'));
System.out.println(
"FontDesignMetrics.getMetrics(font).getHeight() = " + FontDesignMetrics.getMetrics(f).getHeight());

=>

f = javax.swing.plaf.FontUIResource[family=.SF NS Text,name=.SF NS Text,style=plain,size=12]
font.getBaselineFor('a') = 0
FontDesignMetrics.getMetrics(font).getHeight() = 15

@weisJ
Copy link
Owner

weisJ commented Mar 30, 2020

Please add

    @Override
    protected Rectangle getVisibleEditorRect() {
        Rectangle rect = super.getVisibleEditorRect();
        System.out.println(rect);
        return rect;
    }

in DarkTextUI. What is returned for odd/even row height?

@vlsi
Copy link
Contributor Author

vlsi commented Mar 30, 2020

table.getRowHeight() = 23
java.awt.Rectangle[x=5,y=2,width=78,height=18]
table.getRowHeight() = 22
java.awt.Rectangle[x=5,y=2,width=78,height=17]

@weisJ
Copy link
Owner

weisJ commented Mar 30, 2020

Is the issue still occurring? When increasing the rowHeight in TableDemo the Text should only change position every two steps.

@weisJ weisJ changed the title table: text shifts up when start editing and rowHeight is odd [JTable] text shifts up when start editing and rowHeight is odd Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants