Home > Java > javaTutorial > Why Does Swing Rendering Appear Distorted in IntelliJ IDEA with JDK 1.8?

Why Does Swing Rendering Appear Distorted in IntelliJ IDEA with JDK 1.8?

Susan Sarandon
Release: 2024-11-03 08:31:03
Original
298 people have browsed it

Why Does Swing Rendering Appear Distorted in IntelliJ IDEA with JDK 1.8?

Swing Rendering Issues in JDK 1.8

Issue Description:

In IntelliJ IDEA with JDK 1.8.0, Swing GUIs exhibit rendering problems. Font rendering appears distorted, and buttons lose their text when the mouse hovers over them. These issues are absent when using JDK 1.7.0_40. Despite driver updates and other troubleshooting measures, the problems persist.

Resolution Steps:

  1. Check if the issue persists with a simplified project: Create a basic project with only a text area and a button.
  2. Start the application from Event Dispatch Thread (EDT): Use SwingUtilities.invokeLater() to ensure the GUI is initialized and updated on the EDT.
  3. Set the global environment variable "J2D_D3D" to false:

    • Create an environment variable named J2D_D3D with the value false (without quotes). This will disable the Java 2D system's use of Direct3D.

Example:

<code class="java">public static void main(String[] args) {
    SwingUtilities.invokeLater(SimpleClient::new);

    System.out.println("Main EDT: " + SwingUtilities.isEventDispatchThread());
}</code>
Copy after login

Expected Results:

After setting J2D_D3D to false, the GUI should render correctly in both JDK 1.7 and JDK 1.8 environments.

The above is the detailed content of Why Does Swing Rendering Appear Distorted in IntelliJ IDEA with JDK 1.8?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template