Codename One Timer issues

I’m trying to use a timer in Codename One, but it only has “UITimer” which I can’t seem to figure out nor find any examples of.

So I tried the swing timer but it’s giving me the error:
cannot be converted to java.awt.event.ActionListener

with this code

tim = new Timer(1000, new ActionListener() {
      public void actionPerformed(ActionEvent evt) {


Thanks in advance!

It’s because there is an ambiguity about which ActionListener
class your code refers to, as you probably imported the CodeNameOne instead of the Java built-in one, or both have been improted.

In the first case just replace import;
by import java.awt.event.ActionListener;

In the case you need both classes to be imported you’ll have to prefix the class’s name with it’s package name. In your case you want to use the class from the Java package :

tim = new Timer(1000, new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent evt) {

Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Codename One Timer issues

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录