Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java不应到达此错误_Java_Event Handling - Fatal编程技术网

Java不应到达此错误

Java不应到达此错误,java,event-handling,Java,Event Handling,我试图更改源代码的背景颜色,但java给了我内部致命错误消息。你能告诉我我做错了什么吗 import java.awt.*; import java.awt.event.*; import javax.swing.*; class ButtonPanel extends JPanel { private JButton yellowButton = new JButton("Yellow"); public But

我试图更改源代码的背景颜色,但java给了我内部致命错误消息。你能告诉我我做错了什么吗

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    class ButtonPanel extends JPanel 
    {  
        private JButton yellowButton = new JButton("Yellow");

        public ButtonPanel()//constructor
        {  

              //setLayout is a method in JPanel that is called in this constructor
              setLayout (new FlowLayout(FlowLayout.LEFT));
              add(yellowButton);
              actions actionsSpecified = new actions();

              yellowButton.addActionListener(actionsSpecified);
           }
        }

    class actions implements ActionListener
    {
        //actionPerformed is an interface that muse be overriden
        public void actionPerformed(ActionEvent evt)
        {  
            // knows where the event is generated from(from a button, scrollbar etc...)
              JButton source = (JButton) evt.getSource();

              Color colorYellow = Color.yellow;
              source.setBackground(colorYellow);

           /*Color color = getContentPane().getBackground();
           if (source == yellowButton) 
              color = Color.yellow;
           else if (source == blueButton) 
              color = Color.blue;
           else if (source == redButton) 
              color = Color.red;
           setBackground(color);
           repaint();*/
        }
    }


    class ButtonFrame extends JFrame
    {  
            public ButtonFrame()
            {  
                setTitle("ButtonTest");
                setSize(300, 200);
                addWindowListener(new WindowAdapter()
                 {  public void windowClosing(WindowEvent e)
                    {  
                     System.exit(0);
                    }
                 } );

              Container contentPane = getContentPane();
              contentPane.add(new ButtonPanel());
          }
    }

    class ButtonTest
    {  
        public static void main(String[] args)
        {  
            JFrame frame = new ButtonFrame();
            frame.show();  
        }
    }
错误消息--------------------------------------------

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3375), pid=1156, tid=6332
#  Error: ShouldNotReachHere()
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.0-b09 mixed mode windows-amd64 compressed oops)
# An error report file with more information is saved as:
# C:\Program Files (x86)\eclipse\android-sdk-windows\samples\android-8\Snake\hs_err_pid1156.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3375), pid=1156, tid=6332
#  Error: ShouldNotReachHere()
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.0-b09 mixed mode windows-amd64 compressed oops)
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x00000000005fb800):  JavaThread "Unknown thread" [_thread_in_vm, id=6332, stack(0x0000000002590000,0x0000000002690000)]

Stack: [0x0000000002590000,0x0000000002690000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )

Other Threads:

=>0x00000000005fb800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=6332, stack(0x0000000002590000,0x0000000002690000)]

VM state:not at safepoint (not fully initialized)

VM Mutex/Monitor currently owned by a thread: None

Dynamic libraries:
0x0000000000400000 - 0x000000000042e000     C:\Program Files\Java\jre6\bin\javaw.exe
0x0000000077850000 - 0x00000000779f9000     C:\Windows\SYSTEM32\ntdll.dll
0x0000000077420000 - 0x000000007753f000     C:\Windows\system32\kernel32.dll
0x000007fefe010000 - 0x000007fefe07b000     C:\Windows\system32\KERNELBASE.dll
0x000007feff600000 - 0x000007feff6db000     C:\Windows\system32\ADVAPI32.dll
0x000007feffa40000 - 0x000007feffadf000     C:\Windows\system32\msvcrt.dll
0x000007feff6e0000 - 0x000007feff6ff000     C:\Windows\SYSTEM32\sechost.dll
0x000007feff2f0000 - 0x000007feff41d000     C:\Windows\system32\RPCRT4.dll
0x0000000077750000 - 0x000000007784a000     C:\Windows\system32\USER32.dll
0x000007feff590000 - 0x000007feff5f7000     C:\Windows\system32\GDI32.dll
0x000007feffa30000 - 0x000007feffa3e000     C:\Windows\system32\LPK.dll
0x000007feff780000 - 0x000007feff849000     C:\Windows\system32\USP10.dll
0x000007feff2c0000 - 0x000007feff2ee000     C:\Windows\system32\IMM32.DLL
0x000007fefe170000 - 0x000007fefe279000     C:\Windows\system32\MSCTF.dll
0x000007fefdc90000 - 0x000007fefdcaf000     C:\Windows\system32\nvinitx.dll
0x000000006d7f0000 - 0x000000006dee0000     C:\Program Files\Java\jre6\bin\server\jvm.dll
0x000007fefb930000 - 0x000007fefb96b000     C:\Windows\system32\WINMM.dll
0x000000006d760000 - 0x000000006d76e000     C:\Program Files\Java\jre6\bin\verify.dll
0x000000006d3b0000 - 0x000000006d3d7000     C:\Program Files\Java\jre6\bin\java.dll
0x000000006d310000 - 0x000000006d31a000     C:\Program Files\Java\jre6\bin\hpi.dll
0x0000000077a20000 - 0x0000000077a27000     C:\Windows\system32\PSAPI.DLL
0x000000006d7b0000 - 0x000000006d7c2000     C:\Program Files\Java\jre6\bin\zip.dll

VM Arguments:
jvm_args: -Dfile.encoding=Cp1252 -Xbootclasspath:C:\Program Files (x86)\eclipse\android-sdk-windows\platforms\android-8\android.jar 
java_command: dalvik.system.TouchDex
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
PATH=C:/Program Files/Java/jdk1.6.0_23/bin/../jre/bin/server;C:/Program Files/Java/jdk1.6.0_23/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_23/bin/../jre/lib/amd64;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Java\jdk1.6.0_23\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\WIDCOMM\Bluetooth Software\;c:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\eclipse;
USERNAME=
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 37 Stepping 5, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 Build 7601 Service Pack 1

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 37 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht

Memory: 4k page, physical 3920176k(1115300k free), swap 7838504k(4088064k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (19.0-b09) for windows-amd64 JRE (1.6.0_23-b05), built on Nov 13 2010 02:43:42 by "java_re" with MS VC++ 8.0 (VS2005)

time: Fri Jun 10 16:11:50 2011
elapsed time: 0 seconds
这是日志-----------------------------------------------------------------

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3375), pid=1156, tid=6332
#  Error: ShouldNotReachHere()
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.0-b09 mixed mode windows-amd64 compressed oops)
# An error report file with more information is saved as:
# C:\Program Files (x86)\eclipse\android-sdk-windows\samples\android-8\Snake\hs_err_pid1156.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (classFileParser.cpp:3375), pid=1156, tid=6332
#  Error: ShouldNotReachHere()
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.0-b09 mixed mode windows-amd64 compressed oops)
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x00000000005fb800):  JavaThread "Unknown thread" [_thread_in_vm, id=6332, stack(0x0000000002590000,0x0000000002690000)]

Stack: [0x0000000002590000,0x0000000002690000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )

Other Threads:

=>0x00000000005fb800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=6332, stack(0x0000000002590000,0x0000000002690000)]

VM state:not at safepoint (not fully initialized)

VM Mutex/Monitor currently owned by a thread: None

Dynamic libraries:
0x0000000000400000 - 0x000000000042e000     C:\Program Files\Java\jre6\bin\javaw.exe
0x0000000077850000 - 0x00000000779f9000     C:\Windows\SYSTEM32\ntdll.dll
0x0000000077420000 - 0x000000007753f000     C:\Windows\system32\kernel32.dll
0x000007fefe010000 - 0x000007fefe07b000     C:\Windows\system32\KERNELBASE.dll
0x000007feff600000 - 0x000007feff6db000     C:\Windows\system32\ADVAPI32.dll
0x000007feffa40000 - 0x000007feffadf000     C:\Windows\system32\msvcrt.dll
0x000007feff6e0000 - 0x000007feff6ff000     C:\Windows\SYSTEM32\sechost.dll
0x000007feff2f0000 - 0x000007feff41d000     C:\Windows\system32\RPCRT4.dll
0x0000000077750000 - 0x000000007784a000     C:\Windows\system32\USER32.dll
0x000007feff590000 - 0x000007feff5f7000     C:\Windows\system32\GDI32.dll
0x000007feffa30000 - 0x000007feffa3e000     C:\Windows\system32\LPK.dll
0x000007feff780000 - 0x000007feff849000     C:\Windows\system32\USP10.dll
0x000007feff2c0000 - 0x000007feff2ee000     C:\Windows\system32\IMM32.DLL
0x000007fefe170000 - 0x000007fefe279000     C:\Windows\system32\MSCTF.dll
0x000007fefdc90000 - 0x000007fefdcaf000     C:\Windows\system32\nvinitx.dll
0x000000006d7f0000 - 0x000000006dee0000     C:\Program Files\Java\jre6\bin\server\jvm.dll
0x000007fefb930000 - 0x000007fefb96b000     C:\Windows\system32\WINMM.dll
0x000000006d760000 - 0x000000006d76e000     C:\Program Files\Java\jre6\bin\verify.dll
0x000000006d3b0000 - 0x000000006d3d7000     C:\Program Files\Java\jre6\bin\java.dll
0x000000006d310000 - 0x000000006d31a000     C:\Program Files\Java\jre6\bin\hpi.dll
0x0000000077a20000 - 0x0000000077a27000     C:\Windows\system32\PSAPI.DLL
0x000000006d7b0000 - 0x000000006d7c2000     C:\Program Files\Java\jre6\bin\zip.dll

VM Arguments:
jvm_args: -Dfile.encoding=Cp1252 -Xbootclasspath:C:\Program Files (x86)\eclipse\android-sdk-windows\platforms\android-8\android.jar 
java_command: dalvik.system.TouchDex
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
PATH=C:/Program Files/Java/jdk1.6.0_23/bin/../jre/bin/server;C:/Program Files/Java/jdk1.6.0_23/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_23/bin/../jre/lib/amd64;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Java\jdk1.6.0_23\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\WIDCOMM\Bluetooth Software\;c:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\eclipse;
USERNAME=
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 37 Stepping 5, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 Build 7601 Service Pack 1

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 37 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht

Memory: 4k page, physical 3920176k(1115300k free), swap 7838504k(4088064k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (19.0-b09) for windows-amd64 JRE (1.6.0_23-b05), built on Nov 13 2010 02:43:42 by "java_re" with MS VC++ 8.0 (VS2005)

time: Fri Jun 10 16:11:50 2011
elapsed time: 0 seconds

许多示例使用此模式启动Swing应用程序。你可能想试试。整个目的是在Swing线程内创建Swing组件

public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
             JFrame frame = new ButtonFrame();
             frame.show(); 
        }
    });
}
编辑:在仔细阅读问题之后。您不能在Android/Dalvik平台上运行Swing。正如其他人所评论的,如果在Sun JVM上运行,它工作得很好,您似乎是在Android仿真器下运行它。那是行不通的


如果您试图在Android上运行此功能,请更新您的标签,使其包含Android。

适用于我使用最新JDK在Linux上的操作:显示一个带有灰色按钮的框架;单击按钮,它将变为黄色。没有错误。请发布您收到的确切异常消息。实际发布可编译代码+1。我希望这是正常的,而不是例外!错误报告文件中有任何信息吗?检查C:\Program Files(x86)\eclipse\android sdk windows\samples\android-8\Snake\hs\u err\u pid1156.log,并可能发布该日志以查看导致致命错误的原因。我想我没有编译代码。我正在使用eclipse,当我按下run时,它就不工作了。事实上,我经常遇到这个问题。我曾经使用过VisualStudio,我认为当您按下run按钮或“RunasJavaAppision”时也是如此。是否有合适的方法从EclipseIDE运行应用程序。好,但我无法运行我的程序。不知道它为什么会失败真的很烦人。
Java虚拟机:Java HotSpot(TM)64位服务器虚拟机
-这不能Dalvik,是吗?我用你的代码给出了同样的错误。我从命令行运行它。我用javac来编译它。要使用jvm,我应该怎么做?@Dave查看您的错误,我看到以下内容:VM参数:jvm参数:-Dfile.encoding=Cp1252-Xbootclasspath:C:\Program Files(x86)\eclipse\android sdk windows\platforms\android-8\android.jar java_命令:dalvik.system.TouchDexI实际上将我的代码复制到我桌面上的纯文本文件中,并使用命令行进行编译。当我编译它时,它是有效的。当我尝试运行它时,它会给我这个错误消息。线程“main”java.lang.nosuchMethodError中出现异常:main