Skip to content

Commit

Permalink
sync toolkit on repaint
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Jul 10, 2024
1 parent ec3f228 commit 0eda872
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.creme332.controller.console;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Timer;
Expand Down Expand Up @@ -99,6 +100,14 @@ public void run() {
console.setSize(new Dimension(newWidth, console.getHeight()));
console.revalidate();
console.repaint();

/**
* sync toolkit to prevent frame rate issues on linux.
*
* Reference:
* https://stackoverflow.com/questions/46626715/how-do-i-properly-render-at-a-high-frame-rate-in-pure-java
*/
Toolkit.getDefaultToolkit().sync();
}
sidebarAnimating = false;

Expand Down Expand Up @@ -145,6 +154,14 @@ public void run() {
console.setSize(new Dimension(newWidth, console.getHeight()));
console.revalidate();
console.repaint();

/**
* sync toolkit to prevent frame rate issues on linux.
*
* Reference:
* https://stackoverflow.com/questions/46626715/how-do-i-properly-render-at-a-high-frame-rate-in-pure-java
*/
Toolkit.getDefaultToolkit().sync();
}
sidebarAnimating = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ public void refreshGrid(List<TutorialCard> visibleTutorialCards) {
}
gridPanel.revalidate();
gridPanel.repaint();

/**
* sync toolkit to prevent frame rate issues on linux.
*
* Reference:
* https://stackoverflow.com/questions/46626715/how-do-i-properly-render-at-a-high-frame-rate-in-pure-java
*/
Toolkit.getDefaultToolkit().sync();
}

private JTextField createSearchField() {
Expand Down

0 comments on commit 0eda872

Please sign in to comment.