我通过复制教科书中的示例来学习 Java,一旦我开始使用 GUI 类,我就遇到了一些奇怪的故障,如果这是正确的术语的话。正如您在图像上看到的,部分文本丢失。
生成此对话框的代码也不复杂:
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();
}
}
}
当我打开 Java“控制面板”时,我遇到了类似的故障。查看此图像上的 Java 图标。(这里也缺少一段文字。当前选项卡标题应为“Uppdatera”)
我在任何其他应用程序中都没有遇到这个问题,我正在运行最新版本的 Java 平台,以及适用于我的 Nvidia GeForce GT 630M 的最新可用驱动程序。
您对我可以尝试解决的问题有什么建议吗?