Java console loop

断了今生、忘了曾经 提交于 2019-12-05 02:55:32

问题


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


回答1:


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.




回答2:


This occurred to me too when I had a JTextField or JTextArea showing in my program. It only occurred when compiling and running on Java 7 or higher, but not on Java 6.

I don't know why it was happening, but uninstalling HP CloudDrive, a program which came pre-installed on my HP laptop, stopped all those lines showing up.



来源:https://stackoverflow.com/questions/14829794/java-console-loop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!