java compile error_不尋常的“非法轉發”Java編譯錯誤

I'm developing a small program which shows the screen co-ordinates of the mouse pointer in real time, displaying the co-ordinates in the format: "[x;y]"

我正在開發一個小程序,它實時顯示鼠標指針的屏幕坐標,以下列格式顯示坐標:“[x; y]”

Here is a small piece of code which for some reason returns an Illegal forward reference error:

這是一小段代碼,由於某種原因返回了非法的前向引用錯誤:

while(1=1)

{

mouse = MouseInfo.getPointerInfo();

xy = mouse.getLocation();

int x1 = xy.x;

int y1 = xy.y;

String a = "["+x1+";"+y1+"]";

jlbl.setText(a);

}

'mouse' is a PointerInfo object and 'xy' is a Point object which have been declared and have their relevant packages imported. The line "jlbl.setText(""+a);" gives the error, where 'jlbl' is a jLabel declared by NetBeans automatically.

'mouse'是一個PointerInfo對象,'xy'是一個Point對象,它已被聲明並導入了相關的包。行“jlbl.setText(”“+ a);”給出錯誤,其中'jlbl'是NetBeans自動聲明的jLabel。

Any reson to why this is happening?

為什么會發生這種情況有什么共鳴?

Thanks so much to all in advance, I greatly appreciate it.

非常感謝所有人,我非常感謝。

1 个解决方案

#1

0

Promoting OP's comment to answer ...

促進OP的評論回答......

Ah, by replacing the "1=1" with a boolean variable initialised as "true" when the program starts and "false" before it ends fixed that problem. I've also updated my JDK and JRE to the new JDK6 Update 23 and seems to be working fine. A bug maybe?

啊,通過在程序啟動時用一個初始化為“true”的布爾變量替換“1 = 1”,在結束之前用“false”替換修復該問題。我還將我的JDK和JRE更新為新的JDK6 Update 23,似乎工作正常。可能有一個bug?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值