Results 1 to 13 of 13
  1. #1
    Reskaillev is offline Member
    Join Date
    Jul 2011
    Posts
    53
    Rep Power
    0

    Default 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:

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


    Im using Google Chrome and IE9 which are the browsers id like to optimize this for

    Thnx in advance,

    Reskaillev
    Last edited by Reskaillev; 07-24-2011 at 10:32 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    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.

    it gives an error report?
    Please copy and paste the full text of the error.

  3. #3
    Reskaillev is offline Member
    Join Date
    Jul 2011
    Posts
    53
    Rep Power
    0

    Default

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

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Did you try the setFocusable() method?

    Exception: java.lang.UnsupportedClassVersionError: main : Unsupported major.minor version 51.0
    Did you compile the applet with Java version 7?
    Try compiling it with version 6.

    java.lang.UnsupportedClassVersionError: TestCode5 : Unsupported major.minor version 51.0
    I get the above with a class compiled with 7 and executed with 6.

  5. #5
    Reskaillev is offline Member
    Join Date
    Jul 2011
    Posts
    53
    Rep Power
    0

    Default

    Adding this fixed my first question:

    Java Code:
    		
    setFocusable(true);
    requestFocus();
    thnx a lot XD

    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

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Enter: javac -version

  7. #7
    Reskaillev is offline Member
    Join Date
    Jul 2011
    Posts
    53
    Rep Power
    0

    Default

    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.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    explain why it works on this pc
    It works on the pcs that have version 7 installed. That is the newest version.

  9. #9
    Reskaillev is offline Member
    Join Date
    Jul 2011
    Posts
    53
    Rep Power
    0

    Default

    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.

  10. #10
    Reskaillev is offline Member
    Join Date
    Jul 2011
    Posts
    53
    Rep Power
    0

    Default

    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.

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    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

  12. #12
    Reskaillev is offline Member
    Join Date
    Jul 2011
    Posts
    53
    Rep Power
    0

    Default

    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

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    love how the answers mostly just provide cryptic clues
    My idea is to get the OP to read the API doc and think about it. If I just posted the answer, I doubt anyone would bother looking at the doc

Similar Threads

  1. Java Applet Strange Image Loading Problem
    By 1yuchen in forum Java Applets
    Replies: 36
    Last Post: 01-06-2012, 02:06 AM
  2. Embedded applet in jsp its not working.
    By charmi in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 06-17-2011, 11:22 AM
  3. Strange tab key focus traversal behavior in JTable
    By javaexplorer in forum AWT / Swing
    Replies: 0
    Last Post: 05-19-2010, 12:59 PM
  4. Java applet strange painting behaviour
    By sirdori in forum New To Java
    Replies: 1
    Last Post: 01-07-2009, 01:14 PM
  5. setting focus to an applet on a different page
    By hunterbdb in forum Java Applets
    Replies: 4
    Last Post: 11-09-2008, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •