Keep focus in the same window after opening a new window per key-event

I have an application in which user can press on a specific key, and that opens a new window in a JFrame. User might want open a few of such windows in a row by changing the cursor position and pressing the same letter key. But the problem is that with every new window Java VM transfers the focus to that new window. User is forced either to click to regain focus, or to move the mouse out-and-in the window, in which case the focus returns to it as well, assuming the X11 style of focus by cursor position of course.
Is there any way to keep the focus with the window on which the cursor is placed?

In your ActionListener your code should be something like:
JFrame anotherOne = new JFrame();
anotherOne.setVisible(true);
originalFrame.requestFocusInWindow();If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://sscce.org], that demonstrates the incorrect behaviour.
Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

Similar Messages

  • I keep getting redirects if I click on a link. If I click the same link with open in new tab or window it opens fine.

    I get redirects always in current open page. If I click a link and say open in new tab or new window it does not redirect. I've noticed explorer is now advertising built in software to eliminate someone hijacking their browser. If I have to keep searching for tools to clean registry's and browser issues -- I may have to switch back to Explorer or Chrome. Lately my Firefox which I'm most used to is driving me nuts... Why can't you guys provide a tool that cleans the adware, hijacks, etc off the browser? I even downloaded the latest version and I'm still having the same problem-- seems the hijack to redirect remains......

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Do a malware check with some malware scanning programs on the Windows computer.<br>
    Please scan with all programs because each program detects different malware.
    Make sure that you update each program to get the latest version of their databases before doing a scan.
    *Malwarebytes' Anti-Malware:<br>http://www.malwarebytes.org/mbam.php
    *SuperAntispyware:<br>http://www.superantispyware.com/
    *Microsoft Safety Scanner:<br>http://www.microsoft.com/security/scanner/en-us/default.aspx
    *Windows Defender: Home Page:<br>http://www.microsoft.com/windows/products/winfamily/defender/default.mspx
    *Spybot Search & Destroy:<br>http://www.safer-networking.org/en/index.html
    *AdwCleaner:<br>http://www.bleepingcomputer.com/download/adwcleaner/<br>http://www.softpedia.com/get/Antivirus/Removal-Tools/AdwCleaner.shtml
    *Kasperky Free Security Scan:<br>http://www.kaspersky.com/security-scan
    You can also do a check for a rootkit infection with TDSSKiller.
    *Anti-rootkit utility TDSSKiller:<br>http://support.kaspersky.com/5350?el=88446
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • How to go back to the same directory after opening one bookmark instead of having to browse the directory tree again to open another bookmark from the same dir

    I regularly need to check several bookmarks that are stored in the same directory, which usually is a couple of clicks from the main bookmarks menu.
    When I select a bookmark in the tree that I created to organize my bookmarks and it does not give met the web-page/information I was looking for, I want to try another bookmarked web-page in the same directory.
    So I have to click my way through the whole tree again.
    I would highly appreciate if it could be made possible that hovering over the bookmarks menu automatically will unfold the whole tree to the directory where I have been last. That would be a real time saver.

    Try using the Bookmarks Sidebar. '''{Ctrl + B}''' to open and close it. It will stay open until you close it, and when you do close it, the scroll position will remain until you close Firefox.

  • Keeping focus in the viewable window of a scroll pane

    I have many text fields and text areas inside a scroll pane. When I use tab to cycle through these boxes the focus goes out of the viewable window rather then the scroll pane moving to follow the focus. Is it possible for the scroll pane to follow the focus? I would think it is. But I haven't been able to figure out how. Any ideas?
    Thanks,
    Mark

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class test extends JFrame {
      FieldListener fieldListener = new FieldListener();
      final static int fieldNumber = 15;
      JPanel panel;
      public test() {
        super("Focused Scrolling");
        panel = new JPanel();
        panel.setLayout(new GridLayout(0,1));
        JTextField textField;
        for(int i = 0; i < fieldNumber; i++) {
          textField  = new JTextField("TextField # " + i);
          textField.addFocusListener(fieldListener);
          panel.add(textField);
        JScrollPane scrollPane = new JScrollPane(panel);
        getContentPane().add(scrollPane, "Center");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(300,200);
        setLocation(350,200);
        setVisible(true);
      class FieldListener extends FocusAdapter {
        public void focusGained(FocusEvent e) {
          JComponent field = (JComponent)e.getSource();
          Rectangle r = field.getBounds();
          //System.out.println("r = " + r);
          // JComponent method sends message to component's
          // parent who implements scrollable interface
          panel.scrollRectToVisible(r);
      public static void main(String[] args) {
        new test();
    }

  • I would like to be able to start typing a URL directly (with no need to clear the field first) after opening a new tab with my homepage...

    I've just installed the newest desktop version of the Firefox browser because my Opera doesn't feel very well these days. I'm trying to become friends with Firefox, and that's why I've changed the new tab settings in order to have my offline homepage loaded every time I open a new tab. There is an inconvenience — when I press Ctrl+T, the cursor appears at the end of the URL. It means that when I start typing, the letters show in the address bar after the URL of my homepage, so what I need is to clear the field first.
    Is there a way to get rid of this? (If it helpes, I'm currently using Windows 7.)
    I would appreciate if I could just press Ctrl+T, type a URL, and press Enter when I want to go to a website different from my homepage. Thank you for your replies!

    Then you can use (Ctrl+L and) Ctrl+A to select all the text in the location bar or Shift+Home/End.

  • How to put the focus on the address bar, when opening a new tab in Safari?

    Dear users, I'm using Safari 6.0.3 (8536.28.10) under OSX 10.8.3. Until recently, whenever I opened a new tab in Safari, the focus was always on the address bar, which was quite useful. However, since last week, maybe after an update (I don't know exactly), the focus of a new tab is always on the page, not the address bar. How can I go back to the previous configuration? I changed no options, it simply got sudeenly different, and it's quite annoying. Thank you for the help.

    From the Safari menu bar, select
    Safari ▹ Preferences ▹ Extensions
    If any extensions are installed, disable them and test.

  • Everytime I click on a link, instead of loading it on the same page it opens a new tab.

    Suddenly every time I click on a link, it opens it in a new tab i.e.; if I search yahoo from my home page, it opens yahoo in a new tab, then when I click on yahoo mail, it opens yahoo mail in a new tab, and then when I sign in, it opens yet another new tab, etc etc. I must have pressed something, but I don't know how to undo it.

    Try the Firefox SafeMode to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4/5/6/7 SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    If it is good in the Firefox SafeMode, your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes

  • My safari stopped letting me open a new tab in the same window. what happened and how can I get it back to normal?

    When I try and open a new tab in the same window, it wont open a new tab. It leaves the page I am on and goes to the "top sites page."

    Hi,
    If you have got to  Mountain Lion OS X 10.8.2 and therefore Messages version 7.0.1 then double click the individual chats.
    Once they are in separate windows you can chat like that  (That's the way I used to chat - I didn't even use the tabbed chat)
    It is impossible to create a separate Chat window each new chat (you have to separate them off from the main window which also keeps a "copy")
    New chats are added to the main window even if you have used the red button to hide it. (CMD + 0 from the Window menu brings it back)
    10:49 PM      Tuesday; November 20, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Opening .pdfs in the same window/tab.

    I look at a lot of .pdfs (Journal Articles) in my browse. Generally, I only download a fraction of the ones I look at. Recently, Firefox has stopped opening .pdfs in the same window/tab. Instead, it prompts me to download every .pdf I want to look at. I then have to save them, open them on my desktop, look at them, and then delete the ones I do not want to keep. Does anyone know how to get Firefox 10.0.2 to start opening .pdfs in the same window/tab again?

    Adobe PDF Reader is not on your list of Plug-ins submitted with your question (click on "More system details" to the right of your original question). If it is disabled on the Plug-ins list (''Add-ons > Plugins''), click "Enable". If it is not installed on your system (in your Programs folder), then download the installer and run the installer after it is saved to your hard drive (install with Firefox closed).
    *See --> [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox] ('''''NOTE:''''' un-check any items on the Adobe download page that you do not want installed on your system)
    *Also see --> [https://support.mozilla.org/en-US/kb/Opening%20PDF%20files%20within%20Firefox Opening PDF files within Firefox]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
    *'''''Adobe Shockwave for Director Netscape plug-in''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *Adobe PDF Plug-In For Firefox and Netscape: [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.org/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *'''''Next Generation Java Plug-in for Mozilla browsers''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • Open a URL link in the same window as SWF file in indesign CS5

    Hello,
    I am trying to create a SWF file using indesign CS5.  I have created buttons and placed in URL links but they always open another window.  I would like to know if there is a way to have the URL open in the same window that the SWF file has been created.  I tried, putting "_self" to target it in the URL bar, but nothing works.
    Thanks in advance
    TK

    Okay, I found the code but I can't get it to work locally.  If you have a web server maybe you can upload the files (swf and html) after you Publish them:
    import flash.net.URLRequest;
    import flash.events.MouseEvent;
    var myURL:URLRequest = new URLRequest ("http://www.google.com");
    testlink.addEventListener(MouseEvent.CLICK, clickText);
    function clickText(myevent:MouseEvent):void {
    navigateToURL(myURL, "_self");
    you have to have on the stage a link element called "testlink" (see the code above) which would be a Movie Clip with the label testlink.  It can be anything from InDesign:  a button, a rectangle, a circle, a graphic, you get the idea.  Just select that object in Flash and label it testlink or anything you choose but if you change the name from testlink also change the name in the code snippet where the line "addEventListener" is.

  • Open new window in the same Window

    Im developing a project in JavaFX where I wish to open the new window in the same window
    Here is my code :
    Stage st=(Stage)((Node)t.getSource()).getScene().getWindow();
    I tried this but its giving an exception

    It is possible to specifiy a named window instead of _blank.
    So you could use the following instead:
    web.show_document('html/hello.htm','my_window');
    where my_window can be anything you want to call that browser window.
    However, I have discovered that if you put this in a button trigger, the second time you press the button (if the window is still open) it will not take focus - ie. it remains in the background.
    You can get around this by closing the window if it is already open:
    web.show_document('html/close.htm','my_window');
    web.show_document('html/hello.htm','my_window');
    The close.htm needs to contain some javascript to close the window:
    <html>
    <body onload="closeit()">
    <script>
    function closeit()
    window.opener = top;
    window.close();
    </script>
    </body>
    </html>
    Apparently XP SP2 is a little stricter with javascript and may not allow this. Also, not sure if this works in all browsers, I only tried IE6.

  • "Open each folder in the same window" not working

    hey guys, just today, I noticed that whenever i double click a folder, it opens in a new window.  I went to folder properties, and made sure I checked "Open each folder in the same window," and its checked.  I tried switching it on, then off, then restoring all defaults in both those settings and the view settings, and I've tried restarting the computer, even using a system restore point.  No Matter what, whenever I double click a window, it opens in a new window, but if I use the navigation pane, or if I highlight a window and click the open button at the top left, it opens in the same window.  This is very very very annoying, because just navigating my harddrive, I might end up with 20 windows open to reach just 1 file.
    Does anyone know what's wrong?  or how I can fix this? 

    I was experiencing this same issue on my laptop and spent several frustrating hours of searching in vain for a solution. I tried most of the same fixes mentioned here with no success (re-registering DLL's, running the system file checker [sfc /scannow],
    turning off the navigation pane, performing virus scans, etc). After almost giving up, I discovered that I only experienced this behavior when I accessed Explorer from the shortcut which was pinned to my taskbar. When I opened the "Computer" shortcut
    on my desktop, I was able to open individual folders without having new windows open each time. I suspect that this is related to the new design/function of the taskbar in Windows 7. To get the results I wanted, I opted to revert to the "classic" style
    taskbar seen in Windows Vista (AKA the "Quicklaunch" toolbar) by following the instructions here:
    http://www.howtogeek.com/howto/windows-7/add-the-quick-launch-bar-to-the-taskbar-in-windows-7/
    Then, I simply added a new shortcut to "Computer" in the new Quicklaunch toolbar and, "Voila!" - problem solved. Oddly enough, I don't experience the same behavior on my desktop PC which is also running Windows 7. Ain't Microshaft grand?!? (a-hem)

  • Can I set Firefox to open a page link in the same window (not a new tab) so I can just go back to the page instead of having to close the window?

    When I am on some pages, clicking on a article/picture link opens a new tab instead of continuing in the same window. By staying in the same window, I can back click on my mouse and continue on with other reading/links on the original page without manually having to move the mouse and click to close the tab. For example: on news pages, if I click on a financial article, a new tab opens with that linked article on the website's financial site. If I keep going back to the original page w/o closing tabs, I end up with too many tabs open.

    yeah, instead of using multiple windows, you can use multiple tabs inside one window. That way, you can browse multiple websites at once without having to flick back and forth between multiple windows.
    To open tabs of the websites you want to browse, just right-hand click on whatever website you want to visit (For example a site from your bookmarks or a site from a Google search result) and select 'open link in tab'.

  • Opening Hyperlinks inside Excel WebAccess webpart in the Same Window

    I was trying to access Excel Web parts hyperlink like below, but this solution is not working for me.
    $(document).ready(function() {
    $(".ewr-sheetcontainer a").each(function(){
    $(this).attr("onclick","openLink(this)");
    function openLink(Atagproperties)
    Atagproperties.target = "_self";
    Problem is .ewr-sheetcontainer has role="Presentation" atttribute,
    which says it will delete the contents from accessible tree. 
    Is this the reason it is not working for me? or Am I missing anything?
    Appreciate your help on this. Thanks, Maddy

    Hi,
    According to your description, my understanding is that you want to set the hyperlink in Excel Access Web Part opening in the same window.
    As the excel access web part is dynamic loading after the page load, so when the page has loaded, the excel web part element has not been loaded completely.
    I suggest you can use setInterval method to run function circularly until the excel access web part has loaded in the page.
    Here is a code snippet for your reference:
    <script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
    <script type="text/javascript">
    var $a;
    var interval;
    $(document).ready(function(){
    interval = setInterval(ready, 1000);
    function ready()
    $a = $('div.cv-nwl a');
    if($a.html()!=null)
    $a.attr('target','_self');
    clearInterval(interval);
    </script>
    Thanks
    Best Regards,
    Jerry Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Can't open a tab in the same window

    Hello, tell me, please, why can't I open a new tab in the same window. maybe I did something wrong done in the settings?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    *Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

Maybe you are looking for

  • My hard drive broke and I lost all imported photos

    I would always import all my photos from iphone and ipad 2 onto my laptop (windows). My hard drive crashed and I previously had stored a back up of the photos on a flash drive. But I needed the flash drive to install the one time Windows recovery ins

  • Scroll speed increases in InDesign CS4

    I just installed InDesign CS4 on my Toshiba NB505 netbook running Windows 7 Starter. The scroll is driving me nuts. When I use my touchpad scroll, the first few lines scroll smoothly, but then the speed increases to jump several lines with every touc

  • How do I highlight a sentence in an email or make it bold the function disappeared

    Hi Pete, What program are you using to write your emails? - Shelly

  • Web Galleries: retrieving and transferring settings / content

    I use multiple LR databases to manage different websites. For each one, I use a few standard Web Gallery templates to create different pages for photos with different themes. When I first created the pages, I entered different information on each pag

  • Showing Zero Quantities In Query

    In the following Query, I get a list of the Quantities all items ordered and sold within a date range. I am trying to make the query show all quantities Ordered, event if nothing was sold. When I add another AND statement such as: AND T0.[OrderedQty]