Image of the glitch
Java Swing圖形故障?
我被從課本重現例子,只要我使用GUI類我經歷了一些奇怪的故障,如果這是正確的說法學習Java。正如您在圖片上看到的那樣,部分文字缺失。
代碼生成這個對話框並不複雜或者:
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();
}
}
}
我得到similair故障,當我打開Java「控制面板」。看看this image上的Java圖標。 (一段文字丟失在這裏。在當前選項卡的標題應該是「Uppdatera」)
我沒有遇到任何其他應用程序這個問題,我運行一個上最新版本的Java平臺是我的Nvidia GeForce GT 630M的最新驅動程序。
你有什麼建議我可以嘗試解決這個問題?
在事件分派線程的上下文中啓動您的UI代碼,請參閱[初始線程](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html)以獲取更多詳細信息 – MadProgrammer
我似乎要記住顯卡的問題,......但不記得細節。 –
這可能反映了在安裝Windows和Java時選擇的位置之間的不匹配。 – trashgod