Problem restoring applet focus

As an exercise I wrote a Tetris clone in Swing. The game itself is fine, and runs without problems when run standalone in a JFrame. Next, I tried making an applet version of the game. Mostly the same code, just wrapped inside of a JApplet instead of a JFrame. Here's where the problems started.
The applet version seems to run fine in Firefox as long as you do not open a new tab, or click on another already-opened tab. If you go to another tab, then back to the applet's tab, and try clicking on the applet, focus is never regained (or so it seems - the applet no longer responds to keypresses).
In other words:
1. I load the applet in a new tab in Firefox. I can click on the game and play it like I'd expect.
2. I click on some other tab I already have open.
3. I click back on the Tetris applet's tab.
4. I click on the applet and try to start playing again. The applet doesn't respond to any keypresses, no matter how hard I try.
What am I missing here? Hopefully this sounds familiar to somebody. I would post some code but the game is made up of several source files, and I was hoping someone would spot the obvious for me just from a description.
FWIW, using IE7 and Safari, things work as expected - I can switch tabs, then come back and play the game fine. (Although with Safari, sometimes I really have to work to get the applet focus in the first place, but I think that's a different issue).
Thanks for any help!

thorsti16 wrote:
Hi,
i have a similar focus problem. After a click of a Tab and back the focus for keyboard is gone.
I use a shell which has embedded th IE control. My applet has no such problems with jre 1.4.2_10 and older vms.
Which jre version do you use?On Windows it was 1.6.0_03. On OS X, 1.5.0_07. On Fedora Linux, I'm not sure, but it was some release of 1.6. With all three configurations, Firefox had this problem.
Could you please check your applet with 1.4.2_10 ? Perhaps we are facing the same problem.
thorstenUnfortunately my code uses Java 5 features, so I can't test with 1.4.x. I might "backport" to 1.4 just to see if things work that way. But I think I found a solution. Try something like this in your applet's init() method:
applet.setFocusable(false);
gamePanel.setFocusable(true);
gamePanel.setFocusCycleRoot(true);where above, "gamePanel" is the JPanel (or whatever) you added to the applet's content pane, that renders the game, etc. With this code, the "switching tabs" problem is fixed for me on both Windows and OS X. I haven't tested on Fedora yet; when I do I'll post back with the results.
So try the above if you can, and post back with whether it works for you! I suppose if gamePanel is not a java.awt.Container subclass (i.e. if you use java.awt.Canvas), you won't have a setFocusCycleRoot() method to call, but you might not need it in that case. Not sure, haven't tested that either...

Similar Messages

  • Problem with showing focus points in 3.5.1 & 10.9

    I cannot always display the focus points either by using Option + F or View > Show Focus Points on my MBP, late 2012.
    Prior to 3.5.1 & 10.9, either one of these commands would always display or remove, the focus points.
    At times I can restore the focus point display by either closing and opening Aperture or by rebooting OS X.  Today, nothing restores this function.
    Anyone else with this problem or hopefully know of a solution?
    Thanks,  Bill
    FWIW Apple, where is Aperture 4??

    Clem
    There is some data in Console.ap, the latest being about 45 minutes ago.  With a filter set for APERTURE there are several references to :
    "12/3/13 2:53:02.038  Aperture[1324]: The function `CGContextClear' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance."
    and a 13 inch screen full of generally single items.  I do not know how to read / use this info.
    After your message, I went to Aperture and used Option + F, View > Show Focus Points and moused over the small icon representing focal points in the upper right hand corner of the inspector with the info tab selected (just under the JPEG icon) several times but that did not generate any new data in Console.ap.
    Hope this is what you were refering to.
    Bill

  • I recently had to swap out my iphone 4s and I am having problems restoring photos and videos from icloud.  I get a message on my phone that says " the URL you are requesting is not found on this server".  Pics and videos have been deleted too.

    I recently had to swap out my iphone 4s and I am having problems restoring photos and videos from icloud.  When I restored my phone from icloud, half of my pics and videos have been deleted, the pics that were restored on my phone are very blurry, and the videos won't play.  I get a message on my phone that says " the URL you are requesting is not found on this server".  I have erased and reset my phone twice, but every time I do it, more pics and videos are deleted.  I have backed up to icloud and iphoto, however, some of the pics are no longer on iphoto either.  Is there someway to get the videos to play on my phone again?  Make the photos not as blurry as they are now and to restore the pics and videos that have been lost?  I really would love to have them back, this phone is supposed to be the best and right now it doesn't seem to be.  Please help if you can.

    I too have noticed that once i restored from iCloud. Pictures blurry and videos wont play!
    Need help too!!

  • TS3694 hi my name is joe im having a problem restoreing my phone and this error keeps coming up 1015

    i am having a problem restoring my iphone 3g

    That's because your phone is jailbroken.  You will receive no help here.

  • I'm waiting for my new iPhone 5s to be delivered. I lost my iPhone 5 but did have it backed up on my MacBook Pro. I was using iOS6 at the time. Will I have a problem restoring the data to my new iPhone 5s assuming it will come with iOS7?

    I'm waiting for my new iPhone 5s to be delivered. I lost my iPhone 5 but did have it backed up on my MacBook Pro. I was using iOS6 at the time. Will I have a problem restoring the data to my new iPhone 5s assuming it will come with iOS7?

    No, you should not.  There are problems trying to go the other way, but updating a newer iOS release from a backup of an older iOS release has always been supported and is the basic means of setting up a new device from a previous one.

  • Caching problem in Applets - Java Control Panel

    I have a problem of applets being cached in Java Control Panel. Is there a way in Java to stop caching applets programatically in the Java Control Panel.
    There is one way to stop caching files by unchecking "Keep Temporary Files on my Computer" under Java Control Panel --> General --> Settings page.
    But I want to do this programatically using some Java programming/Java Scripting/some parameter in applet tag.
    Some solutions like setting cache_option = No, cache_archive= jar file name in PARAM tag in applet and classloader_cache="false" have been already tried. But noting is seeming to be working out.
    Can somebody please provide a solution.

    Following is the listener status
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ
    ction
    Start Date 11-APR-2007 11:51:12
    Uptime 0 days 0 hr. 1 min. 28 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File I:\oracle\product\10.2.0\db_1\network\admin\listener.o
    ra
    Listener Log File I:\oracle\product\10.2.0\db_1\network\log\listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jbpsouthcbg)(PORT=1521)))
    Services Summary...
    Service "jbpsouth" has 2 instance(s).
    Instance "jbpsouth", status UNKNOWN, has 2 handler(s) for this service...
    Instance "jbpsouth", status READY, has 2 handler(s) for this service...
    Service "jbpsouth_XPT" has 1 instance(s).
    Instance "jbpsouth", status READY, has 2 handler(s) for this service...
    The command completed successfully

  • Problem restoring/adding files

    I have a problem restoring it, because it says I'm not connected to the internet. Even though I can still get online and everything.
    Also, I cannot add files from my hard drive to my ipod, nohing shows up on the actual Ipod.
    Can anyone help me please?

    I do experience the same.
    Can I restore my iPod Nano without internet connection?
    Any response will be very helpful.
      Windows XP Pro  

  • Problem calling applet method using IE

    I've searched through the forum and can't seem to find anything that can help me fix this. I'm trying to call an applet's method using Javascript. This is working fine under Netscape, but not IE. Everything I've read seems to indicate that I'm doing this right, but I'm getting "Object doesn't support this property or method" when I try to call the applet method from IE.
    In this example method, I'm trying to call the applet's countChars method, which should return the length of the string you pass into it. Works under Netscape 6.2, but not IE 6.0
    Here's my applet code:
    import java.lang.String;
    public class test extends java.applet.Applet {
    public static int countChars(String s) {
    return s.length();
    And my HTML
    <HTML>
    <HEAD>
    <script language="Javascript">
    function refreshApplet()
    /*     i = document.forms.myForm.TestApplet.countChars();
         document.forms.myForm.output.value=i; */
         document.forms.myForm.output.value=document.applets["TestApplet"].countChars(document.forms.myForm.input.value);
    </script>
    </HEAD>
    <BODY>
    <APPLET CODE = "test.class" WIDTH = 400 HEIGHT = 400 ALIGN = middle NAME = "TestApplet" scriptable="true">
    </APPLET>
    <br>
    <form name="myForm">
    <input type="text" name="input">
    <input type="button" value="click me" onClick="refreshApplet();">
    <hr>
    <input type="text" name="output">
    </form>
    </BODY>
    </HTML>
    Thanks in advance!
    Craig Drabik
    Sr. Programmer/Analyst
    University at Buffalo

    I have very similar problem, my applet works OK using Netscape (6.2 and 7.0), but with IE 6.0 It only works with windows XP;
    The reported error is "Object doesn't support this property or method"
    Can someone please help me to solve this problem.
    Cheers
    Horus
    This is my code:
    - I call the applet using javaScript and input the method setData with two strings.
    function graphic()
         var dataZenith;
         var dataManual;
         initVariables();
         dataZenith = graphicZENith(); //Call other Javascript functions
         dataManual = graphicManual(); //Call other Javascript functions
         document.AppletOne.setData(dataZenith,dataManual);
    I run the applet with this HTML code:
    <applet NAME="AppletOne" code="Appl.class" width="450" height="450"
    MAYSCRIPT></applet>
    //Applet code/////////////
    import java.awt.*;
    import java.awt.geom.*;
    import java.applet.*;
    import java.util.*;
    public class Appl extends Applet {
         private int [] myArray1 = new int [156];     
         private int [] myArray2 = new int [156];
         private boolean flag = false;
         // maxDataYAxesNumber es usado para dividir el eje de las Y
    public void init()
              setFont(new Font("SansSerif", Font.BOLD, 12));
              setBackground (Color.white);
              setSize(getSize());     
    // Get data and put in an array
    public void setData(String data1, String data2)
              final String DELIMITER = ",";
              final StringTokenizer theTokens1 =
                   new StringTokenizer(data1, DELIMITER);     
              final StringTokenizer theTokens2 =
                   new StringTokenizer(data2, DELIMITER);
              try
                        String dataX = data1;
                        for (int i = 0; i < 156; i++)
                        myArray1[i] = Integer.parseInt(theTokens1.nextToken().trim());
                        myArray2[i] = Integer.parseInt(theTokens2.nextToken().trim());
              catch (NumberFormatException e) {};
              flag = true; //I get the data OK
              repaint();
    public void paint (Graphics g){
    Graphics2D g2d = (Graphics2D)g;
    setData(data1, data2) ;
    if (flag == true)
                   //Call other functions to process the graphic
    else g2d.drawString(" Sorry I can get Data", 100,80);          

  • Problem restoring iTunes backup from Time Capsule

    I had to reformat the hard disk on my daughters macbook and I'm having problems restoring the iTunes library. I have copied the iTunes folder onto the Macintosh Hard drive and receive this error message when I try to open iTunes saying that the .xml file is missing. Would appreciate some help.

    can somebody help i/m basically having the same problem but my error message says an unknown error occurred

  • Problem restoring source system connection post BW system copy

    Hi.
    I am having problems restoring the R/3 connection in our BW system.
    This is the scenario.
    We need to move our BW production system onto a new system, but keep both BW connected to R/3 production for testing etc until cutover to our new BW system.
    Basis performed a system copy and restore of BW production to the new system and ran BDLS.
    When I try to restore the R/3 connection via RSA1 I am getting the following error at the end-
    "A connection already exists there ......." and the message refers to our current/live BW system. The options are to delete the existing or not delete. I have only chosen "do not delete" and therefore the connection is not restored. My concern is that if I choose "delete" this will damage my existing connection between R/3 and the currently live BW system which is we cannot afford to do.
    In our newly copied BW system we are using the existing R/3 SM59 (from system copy), and in R/3 we have created a new SM59 for our new BW system.
    It seems from the error message information that is complains that BW sent R/3 some sort of ID (value = "WS") and that is already taken by the existing BW system. I tried to find where and what this WS value is referring to and the only thing I have found is that in table RSBASISIDOC "WS" is the suffix for transfer structure for that R/3 system. ??? Not sure if this is related for what.
    Thanks for any help

    Hi ,
    Please check with basis or if you can ,then try to restore the source system in BI/BW.This should correct the  inconsistencies between the two systems which is being caused by different Idoc types
    Also check the table RSBASIDOC in the BI system and compare this to R/3 system ,the "basic type" field should be same.
    A restore should work,it has always worked for me.
    Regards
    Amit

  • Problems with the Focus in different JTables

    Hello,
    I got the following problem.
    First of all, I use a Splitpane to show 8 different tables. Four of them (tables 1-4) are placed in the left part of the Splitpane. The other four tables (5-8) are on the right hand side.
    The four tables on the left got their own TableCellRenderer and the four tables on the right got also their own TableCellRenderer.
    If i load the side, I want the focus to be in table 2 and in table 5. How can i do that? Their is never a focus in any of them at the beginning but I need them in TWO of them.
    Secondly, I don't know how I can leave the one focus between tables 1-4 AND tables 5-8????
    I can click through tables 1-4 without any problems but the focus in one of the tables on the right side disappears. The same on the other side if I click through tables 5-8?
    Can anyone give me an answer? I am looking for hours already and I am so frustrated right now.
    Thank you so much....

    http://www.bulletsandbones.com/GB/GBFAQ.html#recordlinein

  • Problem downloading applet in W2K with SP4.

    Hi,
    We are using a Security Applet in our web application for validation purposes. We were using W2K Professional / W2K Server with SP3 and Sun JRE 1.3.x. The application was working as expected.
    We are now testing with W2K Server with SP4 (to upgrade to SP4). The current testing environment is W2K Server with SP4 and Sun JRE1.3.x. Now with the setup, we are facing a problem in downloading the applet (Security Applet). The downloading applet fails and the subsequent loading as well.
    Please advice. Does it requires any particular settings to be done at Client?
    The specs are
    Windows 2000 Server, SP4
    IE 6 SP1
    Sun Jre 1.3.x
    Problem:Downloading applet fails.
    PS: When we test with SP3, we can see the applet downloaded (CAB File), with SP4 it was not found.
    Thanks in Advance,
    Prakash

    Does the w2k sp4 server host your pages and applet?
    If yes then why install the SUN JRE 1.3 on the server, doesn't the client need this?
    Is the cab format supported by SUN jre or is it meant for msjvm and if so why is the client trying to open
    the cab with sun jre?
    http://java.sun.com/j2se/1.4.2/docs/guide/deployment/deployment-guide/upgrade-guide/article-02.html
    What's on the server doesn't have anything to do with the applet. The server is
    just serving it. Forcing the client/consumer of the html page with the applet is trying to open an applet
    with sun jre while the applet is ment for msjvm causes the error.
    The client can fix this by opening IE and check under tools -> internet options -> advanced -> UNCHECK
    the use sun jre ... for <applet tag. For the XP machine you might have a problem. Some of the don't have
    the msjvm at all so there is nothing to run the <applet, I tried to download it at microsoft but was unable
    to find it.

  • HT4993 my iphone wont turn on in order for me to restore it & im having problems restoring it on itunes

    my iphone wont turn on in order for me to restore it & im having problems restoring it on itunes any other suggestions

    there must be a problem with the power button.
    contact apple they will help you
    Apple: 1-800-MY-APPLE

  • Severe Problem in Applets

    I hav problem in Applets by use of threads.The prb. is that i am supposed to create three threads in applets.Thread one will read a file and extract a character array of size 10 from it and Thread 2 will display those characters in Textarea of Applets and after 10 seconds Thread3 will delete those chracters from textarea and next character set of Array of size 10 from Thread one will be assigned to Thread2 and process should go on untill it reads all character from file.Please sort this problem with source code.All are warmly welcome.
    Anuj.

    Thread one will read a file Since applets cannot read from the filesystem you have to use the URL object to read the file and place the
    file in the same location as your applet:
              try {
                   url = new URL(this.getCodeBase(), "yourfile.txt");
                   URLConnection conn = url.openConnection();
                   InputStream in = conn.getInputStream();
                   ByteArrayOutputStream bos = new ByteArrayOutputStream();
                   byte[] buf = new byte[1024];
                   int len;
                   while ((len = in.read(buf)) > 0) {
                        bos.write(buf, 0, len);
                   byte[] data = bos.toByteArray();
    //               String dataString = new String(data,"Shift_JIS"); // depending on your file encoding
              } catch (Exception e) {
                   e.printStackTrace(System.out);
              }How to use threads:
    http://java.sun.com/docs/books/tutorial/essential/threads/index.html

  • Anybody have problems restoring Iphone 4 for verizon after replacing the LCD

    anybody have problems restoring Iphone 4 for verizon after replacing the LCD

    i didnt replace the screen on my verizon iphone, but i have had several problems in the past with restoring, however they are always easily solved for me by plugging into another computer and restoring from there once its restored off that computer you can then plug back into your computer and put your info back on.
    also remember to copy the ipsw from your iphone software updates folder onto a flash drive and onto the computer you are using to update to save yourself form downloading the ipsw on that computer (if it is not already on that computer). then just do an option restore by holding option key when you hit restore and select the ipsw you want to restore to.
    hope this helps

Maybe you are looking for

  • Dynamically Set Subreport Background Color to the Same Value as Main Report Background Color

    I have a report that contains a subreport.  The main report has groupings in it.  I am dynamically setting the background color of the group rows based on an expression.  That part is working fine.  The problem that I am having is that I don't know h

  • Selecting the Checkboxes on Interactive Report

    Hello I have two checkboxes on a Interactive Report: My query is as follows: select apex_item.checkbox(1, empno, 'ENABLED'), apex_item.checkbox(2, deptno, 'ENABLED'), ename, sal from emp; I have a conditional button 'Check N Update' which will invoke

  • Blackmagic Intensity Pro + G5 Quad

    I've just put an Intensity Pro in my G5 Quad 2.5 - Blackmagic software 1.8.4. Tiger 10.4.11. After installing and restart the system udgraded the card firmware automatically. Everything is working fine. Balckmagic says that card won't work on Power P

  • Size limit for files uploaded to htmldb_application_files

    Hi, Is there any size limit for files which are to be uploaded to htmldb_application_files (and then stored as BLOB in db)? Regards, Tom

  • Adobe InDesign ohne Werkzeugpalette, wie soll das gehen?

    Liebe Community ich benutze seit Jahren Photoshop, anfangs auch Bridge, zuletzt nur noch Lightroom zum archivieren. nachdem ich einige online workshops gemacht habe, kam nun die Idee auf auch mal mit InDesign zu arbeiten. Ich habe CS4. laut Adobe gib