开发者

Java ShouldNotReachHere error

I am trying to change the background color of the source but java gives me internal fatal error occurred message. can you tell me what I am doing wrong.

    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();  
        }
    }

Error message --------------------------------------------

#
# 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
#

here is the log -----------------------------------------------------------------

#
# 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
0x00000开发者_Python百科0006d7f0000 - 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


Many examples use this pattern for launching a Swing app. You might want to try it. The whole purpose is to create the Swing components inside the Swing Thread.

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(); 
        }
    });
}

EDIT: After looking through the question more carefully. You cannot run Swing on the Android/Dalvik platform. As other people have commented it works fine if running on a Sun JVM, You seem to be running it under the Android emulator. That will not work.

Please update your tags to include Android if you are trying to run this on Android.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜