7

Image of the glitch
enter image description here

I am learning Java by reproducing examples from a textbook and as soon as I got to using the GUI classes I experienced some weird glitches, if that is the correct term. As you can see on the image, parts of the text are missing.

The code generating this dialog isn't complicated either:

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.Timer;

public class InnerClassTest {
    public static void main(String[] args) {
        TalkingClock clock = new TalkingClock(1000, true);
        clock.start();

        // keep program running until user selects "OK"
        JOptionPane.showMessageDialog(null, "Quit program?");
        System.exit(0);
    }
}

class TalkingClock {
    /*
     * COnstructs a talking clock
     * @param interval the interval between messages (in milliseconds)
     * @param beep true if the clock should beep
    */
    public TalkingClock(int interval, boolean beep) {
        this.interval = interval;
        this.beep = beep;
    }

    /*
     * Start the clock.
    */
    public void start() {
        ActionListener listener = new TimePrinter();
        Timer t = new Timer(interval, listener);
        t.start();
    }

    private int interval;
    private boolean beep;

    class TimePrinter implements ActionListener {
        @Override public void actionPerformed(ActionEvent event) {
            Date now = new Date();
            System.out.println("At the tone, the time is " + now);
            if (beep) Toolkit.getDefaultToolkit().beep();
        }
    }
}

I get similair glitches when I open the Java "control panel". Look at the Java icon on this image. (A piece of text is missing here as well. The current tab title should be "Uppdatera")
enter image description here

I am not experiencing this issue in any other application and I am running an up-to-date version of the Java platform the latest available drivers for my Nvidia GeForce GT 630M.

Do you have any suggestion on things I can try to solve this?

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
user3660280
  • 71
  • 1
  • 2
  • Start your UI code within the context of the Event Dispatching Thread, see [initial threads](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html) for more details – MadProgrammer May 21 '14 at 10:32
  • I seem to remember an issue with graphics cards,.... but can't remember the details. – Hovercraft Full Of Eels May 21 '14 at 10:32
  • This may reflect a mismatch between the locations chosen at installation for Windows and for Java. – trashgod May 21 '14 at 11:15
  • can you post your code how you are starting your swing application? The reason is swing is not thread safe you can check out the details at the bottom of this page http://docs.oracle.com/javase/7/docs/api/javax/swing/package-summary.html – Bilbo Baggins May 21 '14 at 11:41
  • @pathfinder2104: This issue has nothing to do with Swing threading. That much I know 100%. It may deal more with look and feel and graphics card. – Hovercraft Full Of Eels May 22 '14 at 01:17

4 Answers4

2

I had ran into this problem but I fixed it! All I did was after looking at this page, I went and decided to check my graphic card's settings, and I realized this -

https://www.youtube.com/watch?v=UWu3dyXlbAM

Check that for what I did. All I did was go to "Manage 3d Settings" and I clicked "Find" and added "Java 1.8.0_25...." and set it to use nVidia High Performance Processor. I guess new Java just needs a prompt to use the good graphics :D.

  • 1
    thank you, this is actually helped. All this time I thought I had a problem with NVidial Graphics card, but the actual problem was in Intel Integrated Graphics card. I have set preferred graphics processor to "High-perf NVIDIA processor" (in the NVidia Control Panel -> Manage 3d settings; Program Settings -> Add -> Java) and Java UI now works correct. – Dmytro Zharii Jul 05 '16 at 07:04
1

I have long had the same problem as you and I finally found out how to fix it.

Like others have commented, it was a problem with my graphics card driver (I have a NVIDIA GeForce GT 640M). I thought it wasn't at first since I had the latest driver so I tried reinstalling Java with no success. Eventually I rolled back my graphics driver (Control Panel -> Device Manager -> Display Adapters -> (your graphics card name) -> Driver (Tab) -> Roll Back Driver (Button)) and this solved the problem. I tried updating to the newer version and the problem came back so it is definitely the newer driver that was causing the issue.

KRJuggling
  • 75
  • 8
1

Disable Anti Aliasing or FXAA on your graphics card ;)

Mathias
  • 11
  • 1
0

Okay that's a brief answer after hours of research, I hope it'll help others not to bang their head against the wall : try disabling the On-Screen Display support for Java.exe (by adding it in the list) in RivaTuner Statistics Server if it's running on your computer.

Doing so on my computer has instantly made the issue disappear.

Nico
  • 1