java paint problem - black components

旧巷老猫 提交于 2020-02-24 07:50:31

问题


I am having a weird java problem - For some reason quite often when I open a dialog it becomes black. When I force a repaint (for example, draging it out and into the screen again) it draws itself normaly again. The problem seems to occur only on my computer (The same code works for a friend), and its not just one class - it seems that almost every dialogs I open (on different projects) gets this problem. Even JOptionPane.showMessageDialog() gets this problem. Even weirder, it even happens when I am opening the java control panel! What can I do? It drives me crazy! If it matters I am running on windows 7, My GPU is ATI HD4800 with the latest CATALYST driver installed. Thanks in advance!

An example of the problem: http://img233.imageshack.us/i/javablackscreen.png/


回答1:


Generally every problem I've seen regarding java flickering, black windows etc was on an ATI card. Even I have the issue on HD3450 and Win7 64-bit.

See also: https://superuser.com/questions/266332/flickering-java-application-gui-on-windows-7




回答2:


Happened to me on my ATI Radeon HD 5670 with Windows 7 64-bit.

The solution was to use the Catalyst Control Center, and turn the Antialiasing and Anisotropic filtering to "Use Application Settings" instead of the default "Override Application Settings".

This effectively turns off these features on your Java applications, and no more black screen!




回答3:


If the same code works in your friends computer, but not in yours, the problem is in your computer.

But dont give up try a few things before you decide to uninstall windows:

1- Make sure it does not work even if you use methods like repaint(), update or revalidate()

2- At this point there has to be some issue related to compatibility.

-Try updating windows

-Also update to the latest java version

3- Keep searching for your answer here is another question with a similar problem Java applications with Windows 7 - are there compatibility concerns?

4- Maybe the reason is windows 7. I have some college from college that are had similar issues in a programming subject in their laptops with windows 7(64bit). Some of them now use XP and others use Vista, and they don't have those kind of problems.

Good luck!




回答4:


After a recent ati driver update I got the black control problem (and it's 2013 to my greatest astonishment); what helped me was disabling 2d/d3d acceleration:

java -Dsun.java2d.d3d=false -jar whatever.jar


来源:https://stackoverflow.com/questions/5743635/java-paint-problem-black-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!