-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Table row height adjusts on Windows as the font scales with the menu #1623
Conversation
👍 Really nice. What I am concerned about is the number of places we have to put this check. We should really think of a way where configuration changes can flow from the preferences to the GUI elements. Maybe use a event bus for the preferences as well, especially regarding the classes in the GUI package? This could maybe reduce the number of restarts that are required upon changing preferences. What do the other developers think? @JabRef/developers |
It is a bit weird that the rows are not automatically resized on Windows. It seems like this happens for the heading but not the content rows. Maybe easier to send in a bug report to Oracle/Microsoft? |
We are not the first who stumble across this issue. And I doubt that it will be fixed for Swing. |
This isn't really the same thing as in the link, although it is somehow
related as it tries to solve the same problem. Still, bad rendering when
changing the font size is a fundamental issue. (Or is there some automatic
size parameter that must be enabled?)
I also doubt that they will fix it, though. Although it is probably quite
easy as it works for the heading row, so just copy whatever different row
height calculation is there.
|
There is a better solution though (maybe better Googling before coding):
http://stackoverflow.com/questions/15568054/how-to-change-jtable-row-height-globally
I'll try this out. Guess it is look-and-feel dependent but worth a try.
|
As there was recently a issue or forum discussion regarding this topic I just want to make sure that you are aware of two different configurations: There is the option to increase/decrease the table font size using the "View" menu and there is also the "Menu and label font size" in Preferences -> Appearance. The latter setting not only affects the "Menu and label font size" but also sets the font size in the entry editor and potentially at other places... And I just saw that there is also a "Table row height padding" setting which might be reason for the strange height behavior...? |
The current behavior is affected by "Menu and label font size". As far as I am concerned "Table row height padding" is only for the main entry table, as well as the explicit font setting and increase/decrease font size. In the link there are arguments that this is a feature, so they will indeed not change it. (It appears as if the "ideal" default table row height is different on different OS to start with, so they decided to just use the same constant for all systems...) |
a7b2659
to
f660186
Compare
Found a consistent way to do this. It also applied for JTree. I think that the "global" approach is Look-and-feel-dependent so this seems to be the best way to do it. |
@@ -64,6 +65,10 @@ public ChangeDisplayDialog(JFrame owner, final BasePanel panel, | |||
} | |||
tree = new JTree(root); | |||
tree.addTreeSelectionListener(this); | |||
// Fix tree row height | |||
FontMetrics metrics = tree.getFontMetrics(tree.getFont()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these two lines be separated into a utility method, which gets tree
passed? (At the other places, the appropriate other object; table
, ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that as well after changing everywhere... ;-)
LGTM. Please extract the two lines of code to a separate method and then it's good to go (from my side 😇). |
* | ||
* @param table | ||
*/ | ||
public static void correctRowHeight(JTable table) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it also possible to pass JComponent and merge this method with correctRowHeight(JTree tree)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. JComponent doesn't have a setRowHeight method (I checked it before writing the code) and I do not think it is possible to cast from JTree
to JTable
or the opposite.
* master: Fix imports Rename NewFileDialog -> FileDialog Also cancel duplicate finder workflow on close button Removed/moved preferences which are constants implements JabRef#1767: Add Help Button to access new help page Fixed BibTeXMLImporter Set more default file filters in dialogs JabRef#1763 Resolve crossrefs and strings in main table (JabRef#1644) Rewrite bibtexml importer with JAXB parser (JabRef#1666) Moved a few more initialization to GUIGlobals.init() (JabRef#1756) Added program to generate a table of all characters and fixed some characters (JabRef#1766) Improve focus of the maintable after a sidepane gets closed (JabRef#1741) Table row height adjusts on Windows as the font scales with the menu (JabRef#1623) Added more characters to converters (JabRef#1761)
When increasing the menu font size on Windows (at least WIndows 10), the tables also scale but not the row width. This has been fixed in some dialogs earlier, but this is a general fix.
I have no idea how it works on OSX, but on Linux (my CentOS office machine) it seems like the table font is not the same as the menu font.
This is relevant for high resolution displays (although I cannot find the issue that discussed it...)
Before:
After: