Applet looses its focus in IE

Hello, all!
I working with applet that will be used as a simple code editor with highlighting of different programming languages.
This applet based on JTextPane wrapped in JScroll pane. When I test this applet with java applet viewer - all works fine, but now I embedded my applet into html page and try to test it in "live" conditions using IE browser.
When I press TAB key inside of JTextPane the appled looses its focus instead of simply insert an indent as it should be.
Interesting, that this problem reproduces only under IE (in Firefox it works properly).
Maybe someone knows how to workaround this problem?
I'll be very thankfull for answers!
With best regards,
Andrew.

Thanks for all who participated in resolving of my problem. It's eventually has been resolved by myself.
The solution was very complicated and looks like unskilful workaround, but it was one, which really helped.
So now I just want to describe it, maybe someone else will faced the similar problem.
First I added to main class of applet following public method (for manual handling of tab key):
public void handleTab() throws Exception{
     textPane.grabFocus();
     Document doc = textPane.getDocument();
     doc.insertString(textPane.getCaretPosition(), "\t", null);
     textPane.setCaretPosition(textPane.getCaretPosition() + 1);
}After that I simply can invoke this method from JScript. So my wrapping page can be like this:
<HTML>
<HEAD>
<BODY>
<APPLET CODEBASE="." ARCHIVE="editor.jar" CODE="editor.applet.EditorApplet.class" NAME="editor" WIDTH="640" HEIGHT="480" MAYSCRIPT >
</APPLET>
<INPUT name="stub1" type=text onfocus="editor.handleTab();" style="position:absolute; top:100; left:100;">
<INPUT name="stub2" type=text onfocus="stub1.focus();" style="position:absolute; top:150; left:100;">
</BODY>
</HTML>I know, this looks little bit strange, so let me clearify some details and aspects of IE behavior.
- When I press TAB, focus goes to "stub1" input box, which invokes 'editor.handleTab' immediately. But inspite of focus was grabbeg back by applet (invoking textPane.grabFocus()), it is ALSO REMAIS IN BROWSER in inputbox. So when I press TAB again, focus moves not to "stub1" again, but to the next flow control "stub2". So in this case "stub2" must return the focus to "stub1". It is like chain reaction ;-)
- both input box stubs has an absolute positioning and simply hidden under the applet, so all these manipulations are invisible for end-user of applet and looks like 100%-natural behavior of any editable text area.

Similar Messages

  • How to detect if applet lost its focus

    is there a possible way to detect if the applet( the browser itself) lost its focus?
    ANYONE??????????

    it doesnt work for me because i am not using a frame. the applet is embedded in the browser itself.
    You're right. i need to use JSObject to call javascript from java. But i'm still having some problems.
    win = JSObject.getWindow(this);
    str = (String)applet.win.call("myEval", obj);     
    the str should return a 'false' if the applet is out of focus and 'true' if the applet is in focus.
    This is my javascript:
    <script type = "text/javascript">
    var winstate = 'true';
    function myEval() {
         window.onblur = returnFalse();
         return winstate;
    function returnFalse(){
         winstate = 'false';     
    function returnTrue(){
         winstate = 'true';
    </script>
    you know what happens? it always returns 'false' even though the applet is in focus! i don't understand what am i doing wrong. Please help. I am stuck on this.

  • Loosing & gaining focus of a window.

    In my GUI, I have created a window, that is having 2 buttons named "Enabled" & "Disabled".
    MY requirement is: After execution of the window when I will click "Disable" button, the window should loose its focus and then clicking the " Enable" button the window should gain its focus.
    Here I have written the code bellow for visibility of the window, but I haven't written code for the action to be performed by the 2 buttons.
    If any of you have the idea about my requirement, please write me the updated code satisfying my requirement, sothat I'll proceed further.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class window extends JFrame
         public window()
              Container con=getContentPane();
              addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e)
                        System.exit(0);
              JPanel p1=new JPanel();
              JPanel p2=new JPanel();
              JButton b1=new JButton("Enable");
              JButton b2=new JButton("Disable");
              p2.add(b1);
              p2.add(b2);
              con.add(p1,"Center");
              con.add(p2,"South");
              setSize(300,200);
              show();
         public static void main(String arg[])
              new window();
    Regards.
              

    Use a JDialog as the secondary window and make sure you specify the frame as the owner when you create the dialog.

  • My i phone 4  keeps loosing its connection with my Toyota Camry bluetooth-- anyone have any ideas why?

    My i phone 4  keeps loosing its connection with my Toyota Camry bluethoth   does anyone know what I can do about that?

    Ignore the ridiculous post by W1$C.  He posts that regardless of the person's question.
    Things you can do to solve your problem:
    1.  General>Settings>Reset Network settings
    2.  If this is only happening at home, power down your router for a minute, then power it back up.
    3.  Other basic troubleshooting steps outlined in the user guide are to restart, reset, and restore--first from backup, then if needed as a new device.
    Hope this helps.
    GDG

  • Why did my 17"Mac Book Pro loose its ability to output video through it's adaptors?

    Why did my 17"Mac Book Pro loose its ability to output video through it's adaptors? I have S-Video, RC, and an HDMI adaptors that use to work and output video. At somepoint an OS upgrade stoped their functionality. Is this something I can correct? If so, any ideas as to a path to follow?

    2011 and later MacBook Pros shifted to Thunderbolt.
    Pre 2010 MacBook Pros may have a PRAM battery getting old.
    One of these factors may exist.   Not knowing the age of your MacBook Pro, I can't say for certain.

  • Forcing JFrame to lose its focus programatically

    Hello everyone,
    I have a JFrame with a button over it. Now I wants that when I click on the button,
    my JFrame should lose its focus.
    Can anybody tell me whether it is possible in java or not?
    Thanks in advance.

    It depends upon the underlying OS
    On Windows XP it goes to the last application which was in focus.
    For eg- If I first open up a notepad and after that my java application the once my application loses its focus it should go to notepad.
    But i think that will be handled by the OS itself because when you minimizes an application then the application which had the focus before this one will automatically get the focus.

  • Forcing ComboBox to lose its focus when isPopupVisible()==false

    Hi,
    I'm in a situation where I need to force my comboBox to lose its focus, in a case when user clicks the comboBox to pull down the popup but does not click any value inside the comboBox popup. In such a situation I need to force the comboBox to lose its focus.
    I looked for some method like setFocus in comboBox api, but did not find anything such.
    appreciated..

    import javax.swing.*;
    import javax.swing.table.*;
    public class JTableComboSSCCE extends javax.swing.JFrame {
        JTable table;
        DefaultTableModel model;
        public JTableComboSSCCE() {
            initComponents();
            createTable();
        public void createTable() {
            model = new DefaultTableModel();
            model.addColumn("Name");
            model.addRow(new Object[]{"Julia"});
            model.addRow(new Object[]{"Sara"});
            model.addRow(new Object[]{"David"});
            model.addRow(new Object[]{"Mauricio"});
            model.addRow(new Object[]{"Tina"});
            table = new JTable(model);
            scrollPane.setViewportView(table);
            TableColumn firstColumn = table.getColumnModel().getColumn(0);
            JComboBox comboBox = new JComboBox();
            comboBox.addItem("Snowboarding");
            comboBox.addItem("Teaching high school");
            comboBox.addItem("None");
            firstColumn.setCellEditor(new DefaultCellEditor(comboBox));
        void updateTable() {
            model.removeRow(4);
        private void initComponents() {
            scrollPane = new javax.swing.JScrollPane();
            jButton1 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosed(java.awt.event.WindowEvent evt) {
                    formWindowClosed(evt);
            jButton1.setText("Update Table");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jLabel1.setText("1- Click the last row, but do not pick any value, then click outside the table");
            jLabel2.setText("2- Click Update Table button, then click any row to edit cell");
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 670, Short.MAX_VALUE)
                .addGroup(layout.createSequentialGroup()
                    .addGap(21, 21, 21)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(29, 29, 29))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(24, 24, 24)
                            .addComponent(jButton1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addContainerGap(37, Short.MAX_VALUE)
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel2)
                    .addGap(15, 15, 15)
                    .addComponent(scrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE))
            pack();
        private void formWindowClosed(java.awt.event.WindowEvent evt) {
            this.dispose();
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            updateTable();
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new JTableComboSSCCE().setVisible(true);
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JScrollPane scrollPane;
    }

  • JTextArea doesn't loose the focus

    Hi everybody,
    I programmed a graphical interface with two JTextAreas and six JTextFields. Using the program
    means that I delete the text of both JTextAreas and paste new text. An algorithm calculates
    the results. After that I insert new text and start the algorithm again. After two or three deletions
    and insertions one of the JTextAreas doesn't loose the focus and I can't write on it, but I can
    click to another field or area and then I have got two mouse pointer.
    I hope someone has an idea.
    Thank you for your help. Katja

    Please post your code so that somebody may check for
    you.Here the source code of one JTextArea.
    seq1label = new JLabel("Target sequence:");
         sequence1 = new JTextArea("MAEPFSTILGTDGSGGRCKYLNKGIVGLGSYG", 10, 100);
         sequence1.setFont(fontplain);
         sequence1.setBackground(general.BACKCOLOR);
         JScrollPane scrollpane1 = new JScrollPane(sequence1);
         JPanel panelseq1 = general.makePanel();
         panelseq1.setLayout(new BorderLayout());
         panelseq1.add(introduction, BorderLayout.NORTH);
         panelseq1.add(seq1label, BorderLayout.CENTER);
         panelseq1.add(scrollpane1, BorderLayout.SOUTH);
    I hope it is enough.

  • Dir11 is loosing keyboard focus!

    I have a kiosk application running WITHOUT a mouse. All
    inputs is from the keyboard. The app is autostarting when Windows
    starts.
    After playing a Flash animation and a mpeg2 video (Mpeg adv
    xtra) the application looses keyboard focus, wich result in Windows
    warning sound when you press a key and the key is not sent to the
    application.
    The problem is solved if you click with a mouse, but there is
    no mouse as I mentioned. The problem is NOT solved by <alt>
    <tab>-switching forth and back.
    I know this is an old MX2004 bug, and the work around then
    was to set the document type to "tool". But this is not helping in
    Dir11.
    Anyone hwo has a work around?
    Where to report bugs now a days? Does Adobe care at all?
    (It's not easy to even find the Director support pages!)

    Hi,
    maybe you can use one of the Xtras than can simulate a
    mouseclick?
    Richard
    "stageit ab" <[email protected]> wrote in
    message
    news:ganvvs$2as$[email protected]..
    >I have a kiosk application running WITHOUT a mouse. All
    inputs is
    >from the
    > keyboard. The app is autostarting when Windows starts.
    > After playing a Flash animation and a mpeg2 video (Mpeg
    adv xtra)
    > the
    > application looses keyboard focus, wich result in
    Windows warning
    > sound when
    > you press a key and the key is not sent to the
    application.
    > The problem is solved if you click with a mouse, but
    there is no
    > mouse as I
    > mentioned. The problem is NOT solved by <alt>
    <tab>-switching forth
    > and back.
    >
    > I know this is an old MX2004 bug, and the work around
    then was to
    > set the
    > document type to "tool". But this is not helping in
    Dir11.
    >
    > Anyone hwo has a work around?
    > Where to report bugs now a days? Does Adobe care at all?
    (It's not
    > easy to
    > even find the Director support pages!)
    >
    >
    >

  • Why would my SG200-26P loose its fixed ip?

    Hi there.
    I have 4 of these switches that seem to have lost their ips. They were fixed to 192.168.x.6,7,8,9 via the management inteface.
    It seems there was a power outage that reset most of the network. It was for less than 1 hr. Once things powered back up, it seems i can not get back into the switches. We have had a power outage event over the years before, and they came back up just fine.
    We cant ping that ip, or see the switch request DHCP on the network. These are off site, and I am trying to figure out how to get into it.
    We tried to set a secondary address for out nework to include 192.168.1.0 into the lan so IF it is set to .1.254 for some reason, that we can get to it. But i beleive all 4 switches which are on the same lan having the same address would give us conflict to not be able to get in or have a stable connection to them even with the subnet allowing access to .1.254
    Luckily, whatever state they are in, the LAN us up and running which is on a different subnet than .1
    So, must i do a truck roll? Will a reboot possibly help get them back up if they are rebooted 1 by 1?
    The only thing i can think of is that maybe they didnt get DHCP becuase they are connected upstream via their gbic fiber port? Maybe the fiber port isnt ready in time for the DHCP request from the switch?
    Any advice as to how this switch would loose its ip would be very helpful.
    Thanks
    Sam

    Hi Sam, it sounds like no one saved the running config to the start up config. Every change made to the switch does not automatically write to a memory. It behaves much like a computer. If a computer reboots with something in RAM, it is gone, it must save to the hard drive to keep coming back.
    The switch is most likely at a factory default state. If the switches connected to a DHCP network, they obtained an address from the DHCP server.
    Once you get back in to them and fix the switches the way you'd like, make sure to click the Save button at the top right and save the running config to start up config and reboot the switch to test it out.
    -Tom
    Please mark answered for helpful posts

  • Why does FCP looses its source file reference when files are copied

    Why does FCP looses its source file reference when files are copied from another project??
    i have this happen all the time, I move all my media to another drive and files that originated in another project do not reconnect because they have lost there source?
    Any way to fix this mess? i am in the middle of reconnecting 400 files by hand one at a time!!!
    Thanks, mark

    Because you changed the file path. From one hard drive to another...the hard drive name is no doubt different, and then if you have the files in different folder structures then yeah, it will lose the connection to that media.
    Best thing to do is to clone your media drive, or name the other drive the same name, and keep the exact same file structure (folders in folders) as the original drive. Then you won't need to reconnect.
    Shane

  • HT1212 hello i forgot my passcode and i need to restore my iphone with out loosing its data can u please help me

    can u please say me how to restore my iphone wen i forgot my pass code with out loosing its data

    If you have not had a backup of the data before, you need to check this support document you linked here from about removing the passcode. Without a current backup, you are going to lose data.

  • Adobe CC Updated disappears, if it loose the focus!

    Hi!
    I updated the Adobe CC Updater, but I've still this issue:
    If the Adobe Updater loose the focus, it disappears. Then I've to open it again via the Systray.
    That is a little bit annoying, especially if you want just to use your password manager to login again, as the updater continues to forget the login credentials.
    Could you please disable this "feature", that the Adobe CC Updater disappears, if it loose the focus?
    The only positive thing is: It really just disappears and does not close! So the entered information are still there, but the window is not available until you reopen it. But still it's a little bit annoying!
    Thanks

    https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform for bugs or feature requests

  • Premiere CS4 looses its memory

    My Premiere CS4 (4.1.0.) sometimes looses its "memory" of the last opened project - meaning that at the opening screen, when usualy the last project is offered to be opened again, there are no projects anymore. So I have to go over the button "open project". That wouldn't be a big deal but there are other things which are lost too, as example the keyboard settings and sometimes some already used files were be analyzed newly (e.g. mp3 files).
    Has anyone any idea what could be the cause of this behaviour? Strangely the phenomenon does not always occur but I have not find out yet, when it occurs and when not. Any idea?
    Thanks for your help!
    PS: working with vista64bit, SP2, working on a WD-Velociraptor-system-HD and my projects on a RAID-10 with 4 HD, 8GB DDR-2 RAM, CPU Quad9550

    Thanks everybody for your help and your suggestions.
    @Jeff - no, I'm always logged in with the same account - and I'm also the only user on the machine - so I don't think this is the reason.
    @AndreyV - possible, but as far as I know, I don't have any cleaning tools working in the background
    @ the_wine_snob - I don't think, that it's a problem of Windows, because all other applications run properly - the last opened word and excel documents are always remembered normaly, so I think...
    @SFL46' suggestion could be the cause of my problem  - in fact I do have the folder "my documents" (and in it the PP.prproj-files) at a diffrent location than Windows Vista usually puts it. I moved it to my RAID-drives (instead of the system drive c where usually the "user"-folders are located). I never had any problems with PP CS3 or the earlier versions, but that could be the reason of this behaviour (specially because PP doesn't always looses the last opened documents). I will move the prproj-files to the user-folder on the system drive and will report my experience here.
    Thanks!
    Phil

  • Window with applet tag gains focus prior to new window browser window

    setup a :
    1. sample index.html page:
    <HTML>
    <HEAD>
    <script>
    var _load=function(){window.open('test.html');};
    window.attachEvent("onload", _load);
    </script>
    </HEAD>
    <BODY>
    <applet code=Index name=Index width=1 height=1 align=baseline>
    </BODY>
    </HTML>
    2. and child test.html window of the above (opened during onload event)
    <HTML>
    <HEAD>
    <TITLE>1</TITLE>
    <script>
    var _load=function(){window.focus();};
    window.attachEvent("onload", _load);
    </script>
    </HEAD>
    <BODY>
    TEST PAGE
    </BODY>
    </HTML>
    when a test.html page is opened focus is temporarily shifted back to the index.html page and
    only later back to the test.html page (window.focus()) call in that page sets the focus, not always
    suceeds, a further code is required to do a retry)
    when the applet is removed from the index.html page, problem goes away, it is if the applet tag
    has priority in terms of window focus
    byproduct of this is also annoying flicker, (while the focus is shifted between index.html and test.html page)
    this problem is only happening with SUN JVM (and I dont know if its a defect or by design)
    SUN JVM tested:
    Java(TM) Plug-in: Version 1.4.2_03
    Using JRE version 1.4.2_03 Java HotSpot(TM) Client VM
    suggestions, workarounds? appreciate in advance

    tested following matrix of browser/VM
    Platform Result:
    MS IE and Microsoft (R) VM for Java, 5.0 Release 5.0.0.3810 (with success, no focus problems)
    MS IE and Java(TM) Plug-in: Version 1.4.2_03 (focus problems, in the case of
    two applets one coded on the
    main page the other on the pop-
    up window)
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
    Plug-in: Version 1.4.2_03 Using JRE version 1.4.2_03 Java HotSpot(TM) Client VM
    (focus problems, in the case of one applet on
    the main page or in the case of two applets
    one coded on the main page the other on the
    pop-up window)
    Please see revised test case source code (to support above configurations, as well inclusion of the second
    applet to address discrepency in behaviour between Mozilla and IE (with SUN JVM)
    <HTML>
    <HEAD>
    <script>
    String.prototype.contains=function(s){return(this.toLowerCase().indexOf(s.toLowerCase())!=-1);};
    var u_n=navigator;
    var u_agt=u_n.userAgent.toLowerCase();
    var u_MSIE=(u_agt.contains("msie"));
    var _load=function(){window.open('test.html');};
    if (u_MSIE)
    window.attachEvent("onload", _load);
    else
    window.addEventListener("load", _load, false);
    </script>
    </HEAD>
    <BODY>
    <applet code=Index name=Index width=1 height=1 align=baseline>
    </BODY>
    </HTML>
    <HTML>
    <HEAD>
    <TITLE>1</TITLE>
    <script>
    String.prototype.contains=function(s){return(this.toLowerCase().indexOf(s.toLowerCase())!=-1);};
    var u_n=navigator;
    var u_agt=u_n.userAgent.toLowerCase();
    var u_MSIE=(u_agt.contains("msie"));
    var _load=function(){window.focus();};
    if (u_MSIE)
    window.attachEvent("onload", _load);
    else
    window.addEventListener("load", _load, false);
    </script>
    </HEAD>
    <BODY>
    TEST PAGE
    <applet code=Test name=Test width=1 height=1 align=baseline>
    </BODY>
    </HTML>
    Index.java source code:
    public class Index extends Applet {
    public synchronized void init() {
    public synchronized void start() {
    public synchronized void stop(){
    public synchronized void destroy(){
    Test.java source code:
    public class Test extends Applet {
    public synchronized void init() {
    public synchronized void start() {
    public synchronized void stop(){
    public synchronized void destroy(){

Maybe you are looking for

  • Printing in SAP Script

    Hi Experts, I am creating a Purchase order (ME21) for a one time  vendor (Dummy PO)created and make a printout on Script that shows my material master that data not provided by me and the data provided by me is not come on printout at the same time I

  • Connecting midi device to imac

    computer won't recognize yamaha piano (cvp) thru midi to usb cable imac intel   Mac OS X (10.4.4)  

  • In the dvd player, the button to go back chapters does not work!

    Hi.. I need some help please. In the dvd player when I ask to skip a chapter, the command works fine, however when I ask to return to the previous chapter it back to the beginning of the same chapter. And only works if I press the back button twice q

  • Cluster does not work after a while

    Hi :           I have 2 clustered EJB server, the IP address is 192.168.0.226 and           192.168.0.227.           A servlet server is calling these two EJB servers with           t3://192.168.0.226,192.168.0.227:7001           All three machine us

  • HTTPService issues

    I'm having difficulty in getting a simple HTTPService call to work I've got a simple MySQL DB, using one table with 3 records and 3 fields I'm evaluating Flexbuilder 2 and can't seem to construct a valid result My PHP page call returns the following