Results 1 to 13 of 13
- 07-24-2011, 10:22 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
Getting Focus in an embedded applet? And strange error reports
So I got this java applet turned into .class by using the JDK and I am having some problems:
1. The java applet doesn't get focus automatically, you still have to click to mouse to unblur it
I tried using javascript to give focus to the applet to no result. And I tried putting the "requestFocus()" function in the init part of my applet, but again: no result.
So what is an easy way to get this done?
2. For some reason the java applet works on my laptop, but if I try it on another computer it gives an error report? what could be the reason?
error report:
3. Not really about the java code, but what is the good method to get an applet embedded in a html file?? I searched google and found like 100 methods with object and so on, but the ones I tried just don't work! I'm using the deprecated <applet> method now which is...well..deprecated..Java Plug-in 1.6.0_26
Using JRE version 1.6.0_26-b03 Java HotSpot(TM) Client VM
User home directory = C:\Users\Bronders
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
Exception in thread "AWT-EventQueue-2" java.lang.InternalError: couldn't create component peer
at sun.awt.windows.WComponentPeer.checkCreation(Unkno wn Source)
at sun.awt.windows.WComponentPeer.<init>(Unknown Source)
at sun.awt.windows.WCanvasPeer.<init>(Unknown Source)
at sun.awt.windows.WPanelPeer.<init>(Unknown Source)
at sun.awt.windows.WWindowPeer.<init>(Unknown Source)
at sun.awt.windows.WFramePeer.<init>(Unknown Source)
at sun.awt.windows.WEmbeddedFramePeer.<init>(Unknown Source)
at sun.awt.windows.WToolkit.createEmbeddedFrame(Unkno wn Source)
at sun.awt.windows.WEmbeddedFrame.addNotify(Unknown Source)
at sun.plugin2.main.client.PluginEmbeddedFrame.addNot ify(Unknown Source)
at sun.awt.windows.WEmbeddedFrame.<init>(Unknown Source)
at sun.plugin2.main.client.PluginEmbeddedFrame.<init> (Unknown Source)
at sun.plugin2.main.client.PluginMain$StartAppletRunn er.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.UnsupportedClassVersionError: main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.UnsupportedClassVersionError: main : Unsupported major.minor version 51.0
Im using Google Chrome and IE9 which are the browsers id like to optimize this for
Thnx in advance,
ReskaillevLast edited by Reskaillev; 07-24-2011 at 10:32 PM.
- 07-24-2011, 10:35 PM #2
What classes are used in the applet's GUI? Can they receive focus? Have you tried setFocusable()?
Can you make a simple applet that compiles and will execute in a browser to demonstrate the problem.
Please copy and paste the full text of the error.it gives an error report?
- 07-24-2011, 10:44 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
Only the applet father class is used, no other components are made
So it could be that the applet (without any components) cannot receive focus this way?
I added the error report XD you kind of ninja'd me
I shall try to make a simple applet, stay tuned....
- 07-24-2011, 10:50 PM #4
Did you try the setFocusable() method?
Did you compile the applet with Java version 7?Exception: java.lang.UnsupportedClassVersionError: main : Unsupported major.minor version 51.0
Try compiling it with version 6.
I get the above with a class compiled with 7 and executed with 6.java.lang.UnsupportedClassVersionError: TestCode5 : Unsupported major.minor version 51.0
- 07-24-2011, 11:01 PM #5
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
Adding this fixed my first question:
thnx a lot XDJava Code:setFocusable(true); requestFocus();
Well I use the JDK to compile my .java files
Lets put this in kitchen recipe:
1. I open Command Prompt
2. I go to the file with the java file in: CD C:\.....
3. I write "javac SillyNameHere.java" and it makes the .class file
So how to compile it as a version 6 java file?
I have no idea what version of the JDK im using :s
- 07-24-2011, 11:05 PM #6
Enter: javac -version
- 07-24-2011, 11:06 PM #7
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
javac 1.7.0-ea
EDIT:I could also be the case that my JDK is outdated? But that still doesn't explain why it works on this pc and not on the others?...Last edited by Reskaillev; 07-24-2011 at 11:09 PM.
- 07-24-2011, 11:12 PM #8
It works on the pcs that have version 7 installed. That is the newest version.explain why it works on this pc
- 07-24-2011, 11:17 PM #9
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
i'll try this:
javac -target 1.6 file.java
EDIT: doesn't work but I think the general direction i'm trying to take is ok...-_- It says: javac: target release 1.6 conflicts with default source release 1.7
EDIT 2: I tried to use: javac -source 1.6 file.java and it generated a class without errors, but it still doesn't work...D: (-source = provide source compability with specified release)
EDIT3: I'm thinking 1.7 comes directly with the new Eclipse: Indigo?Last edited by Reskaillev; 07-24-2011 at 11:52 PM.
- 07-25-2011, 12:45 AM #10
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
Can't get it to work... noone has a solution for this? C'mon im sure you are all working with 1.7!

EDIT: Just read that 1.7 will go public the 28th July, so problem will fix itself then? But stil..wondering how to do this...Last edited by Reskaillev; 07-25-2011 at 01:25 AM.
- 07-25-2011, 03:45 AM #11
Read the API doc for the javac command.
And think about the error message you got:
javac: target release 1.6 conflicts with default source release 1.7
- 07-25-2011, 02:41 PM #12
Member
- Join Date
- Jul 2011
- Posts
- 53
- Rep Power
- 0
I wrote the entire API doc for javac (using javac -help)
but only came across -source and -target that could be able to help me...
Tried source and target (both set to 1.6)
but....VICTORY!!! seems that you had to set source AND target both to 1.6 for it to work XD
PS: Also love how the answers mostly just provide cryptic clues :p
- 07-25-2011, 03:25 PM #13
Similar Threads
-
Java Applet Strange Image Loading Problem
By 1yuchen in forum Java AppletsReplies: 36Last Post: 01-06-2012, 02:06 AM -
Embedded applet in jsp its not working.
By charmi in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 06-17-2011, 11:22 AM -
Strange tab key focus traversal behavior in JTable
By javaexplorer in forum AWT / SwingReplies: 0Last Post: 05-19-2010, 12:59 PM -
Java applet strange painting behaviour
By sirdori in forum New To JavaReplies: 1Last Post: 01-07-2009, 01:14 PM -
setting focus to an applet on a different page
By hunterbdb in forum Java AppletsReplies: 4Last Post: 11-09-2008, 06:21 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks