attempt to fix examples window spinning in Windows (#5246)

This commit is contained in:
Ben Fry
2018-04-07 10:47:25 -04:00
parent 3434bc6ca6
commit 84d458f5b9
@@ -23,6 +23,7 @@
package processing.app.ui;
import java.awt.Component;
import java.awt.EventQueue;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
@@ -50,12 +51,16 @@ public class ZoomTreeCellRenderer extends DefaultTreeCellRenderer {
int high = getPreferredSize().height;
if (high != 0) {
// Source Sans leading too short, so also add 15% for nicer spacing
high = (int) (high * 1.15f);
int current = getSize().height;
if (current != high) {
// This seems to be causing an infinite loop on Windows
final int targetHeight = (int) (high * 1.15f);
int currentHeight = getSize().height;
if (currentHeight != targetHeight) {
// Using invokeLater() to avoid infinite loop on Windows
// https://github.com/processing/processing/issues/5246
tree.setRowHeight(high);
EventQueue.invokeLater(new Runnable() {
public void run() {
tree.setRowHeight(targetHeight);
}
});
}
}
return super.getTreeCellRendererComponent(tree, value, selected,