mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
attempt to fix examples window spinning in Windows (#5246)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user