使用java 1.6.0_29时出错

时间:2012-03-15 15:10:40

标签: java applet

我已经制作了一个在学校的Linux计算机上运行良好的java applet(运行java 1.6.0_23)。但我最近给自己买了一个mac并在其上安装了java 1.6.0_29。问题是,当我在我的新Mac上运行程序时,我在运行时遇到了几个错误:

Dentist1 is treating patient10


Dentist0 is treating patient11
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
    at sun.awt.RepaintArea.paint(RepaintArea.java:249)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
at java.awt.Component.dispatchEventImpl(Component.java:4811)
at java.awt.Component.dispatchEvent(Component.java:4565)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:679)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:638)
at java.awt.EventQueue$1.run(EventQueue.java:636)
at java.security.AccessController.doPrivileged(Native Method)
at    java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at     java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)


Dentist1 is treating patient12
at java.awt.EventQueue$2.run(EventQueue.java:652)
at java.awt.EventQueue$2.run(EventQueue.java:650)
at java.security.AccessController.doPrivileged(Native Method)
at       java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:649)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at sun.awt.RepaintArea.paint(RepaintArea.java:249)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
at java.awt.Component.dispatchEventImpl(Component.java:4811)
at java.awt.Component.dispatchEvent(Component.java:4565)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:679)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:638)
at java.awt.EventQueue$1.run(EventQueue.java:636)
at java.security.AccessController.doPrivileged(Native Method)
at  java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at  java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:652)
at java.awt.EventQueue$2.run(EventQueue.java:650)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:649)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Dentist0 is treating patient13


Dentist1 is treating patient14´

如果你想知道,小程序应该模拟牙医诊所,在候诊室里有2名牙医和4把椅子。我有一个秘书螺纹课程,确保只有4名患者进入候诊室,如果患者不忙,患者可以去看牙医,两个等待病人然后治疗的牙医线程。

对于前10名患者似乎运行良好,然后我得到了这些错误,之后它继续运行没有错误。 我不知道你是否有可能在没有查看我的代码的情况下帮助我解决这个问题,但我会感激任何建议,为什么这只会在更新的java版本中发生。我的代码可能有问题,java 1.6.0_23无法检测到吗?

2 个答案:

答案 0 :(得分:0)

编写正常工作的代码相当容易。错误是在您更改操作系统,硬件或Java版本之前,错误不会显示。从Java 5.0升级到Java 6或6到7的各种问题都来自这些错误。

您可能正在破坏Swing对象模型,但Java 6更新23没有注意到。但是,它更可能是您正在使用的硬件/操作系统的差异。

我会下载Java 6 update 23来检查这个(或在两个系统上使用相同的版本)

答案 1 :(得分:0)

在处理空值时,Java类的代码并不是最好的。检查是否为Swing组件提供了一些空值,并将它们更改为非空值。