java输入对话框循环,Java控制台循环

Noticed no one has answered this yet on here so thought I'd give it a shot again. Hopefully someone can help. Already went to my Java teacher and he just said I messed something up and couldn't figure it out so I can't move on.

Anywho, here's my test code:

import javax.swing.JOptionPane;

public class Test {

public static void main(String[] args) {

System.out.println("hello");

JOptionPane.showInputDialog("Enter a real number");

}

}

And this is what I receive in console:

hello

03:30.28 1[dbg] In DllGetClassObject

03:30.28 2[dbg] CShellExtClassFactory::CShellExtClassFactory()

03:30.28 3[dbg] CShellExtClassFactory::QueryInterface()

03:30.28 4[dbg] CShellExtClassFactory::CreateInstance()

03:30.28 5[dbg] CShellExt::CShellExt()

03:30.28 6[dbg] Looping before Zumo is running

03:30.28 7[dbg] CShellExt::QueryInterface()==>IID_IShellIconOverlayIdentifier

03:30.28 8[dbg] CShellExt::AddRef()

03:30.28 9[dbg] CShellExt::AddRef()

03:30.28 10[dbg] CShellExt::Release()

03:30.28 11[dbg] CShellExt::QueryInterface()==>IID_IShellIconOverlayIdentifier

03:30.28 12[dbg] CShellExt::AddRef()

03:30.28 13[dbg] CShellExt::Release()

03:30.28 14[dbg] Entering CShellExt::GetOverlayInfo

03:30.28 15[dbg] Icon path: C:\Program Files (x86)\Hewlett-Packard\HP CloudDrive\icons\deflated.ico

03:30.28 16[dbg] Exiting CShellExt::GetOverlayInfo successfully.

Any help would greatly be appreciated. I have already tried re installing everything I could which include eclipse and the JDK 1.7. I also noticed this only happens when I try to use the dialog JOptionPane so far. I am using a windows 7 system.

Thanks guys

解决方案

Just a guess, because I have ran into strange AWT/Swing issues on other systems, you could try this here (sometimes the underlying UI system gets not initialized properly, but as I said, this is just a guess):

public class Test

{

public static void main(String[] args)

{

SwingUtilities.invokeLater(new Runnable()

{

@Override

public void run()

{

System.out.println("hello");

JOptionPane.showInputDialog("Enter a real number");

}

});

}

}

By using invokeLater you force the whole UI system to get initialized (the EDT to be started and the option pane showed from inside the EDT), I had to use this trick e.g. for getting my SDL bindings under OSX to work. invokeLater initializes the whole Cocoa system for me.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值