Setting focus to component in new tab

I have a static function in my main class with a JTabbedPane as a parameter...the function does this:
//Add a tab
tabs.addTab("New File", new STab());
tabs.setSelectedIndex(tabs.getTabCount()-1);
          ((JPanel)tabs.getSelectedComponent()).getComponent(0).requestFocusInWindow();
I run this function from two different places in my code: one is from a menu I created when a user mouse clicks on the menu item. The other is when the user presses Ctrl+T...this goes through a KeyEventDispatcher that I set up on top of all my other components.
The problem is this: when I create a new tab through the menu, the code that selects the first component in my tab works, however when I do it with Ctrl+T that component is not selected. Both of these methods run the same function...the only difference is that the Ctrl+T method goes through a class which implements my own interface.
Any ideas?

tabs.setSelectedIndex(tabs.getTabCount()-1);
this will select the last tab in your tabbed pane...
I assume the next line is when the tabbed pane is hidden behind some other frame, it will bring it to front.
((JPanel)tabs.getSelectedComponent()).getComponent(0).requestFocusInWindow();
couldn't you just go:
tabs.getSelectedComponent().requestFocus(); ? I'm not 100% what you're tryin to do in the last line.

Similar Messages

  • How can I set home page for a new tab? how can i get firefox to open the home page every time i open a new tab in Windows vista home basic??

    How can I set home page for a new tab? how can i get firefox to open the home page every time i open a new tab in Windows vista home basic??
    == This happened ==
    Every time Firefox opened

    Firefox can have multiple home pages if you wish. Each home page that will open when starting Firefox is separated by the "|" character.
    See: http://support.mozilla.com/en-US/kb/How+to+set+the+home+page
    To have new tabs open a specific web site, add one of the following extensions:
    http://sogame.awardspace.com/newtaburl/
    https://addons.mozilla.org/en-US/firefox/addon/777

  • I downloaded the new version of Mozilla and tried to install an add-on to allow me to set the home page for new tabs. The app says it has downloaded but does not open new tabs as my home page (google) - any suggestions what I can do?

    I downloaded the new version of Mozilla and tried to install an add-on to allow me to set the home page for new tabs. The app says it has downloaded but does not open new tabs as my home page (google) - any suggestions what I can do?

    I've been working on this all day!!! I've tried everything I know of and can't get it to load either. Sounds like lots of people are having problems. Here is what I have so far...I have uninstalled EVERYTHING on my pc from apple and reinstalled itunes to no avail. I have tried all sorts of things I've read as fixes online. NOTHING has worked. Here is something interesting that i have noticed though. my main pc (which is the one i have always managed my itunes account with for years) is a 32 bit system running windows 7. Yesterday I installed itunes for the first time on my new netbook which is a 64 bit (windows 7) system and it works just fine. i have three other laptops (all window 7) in my household that are all 64 bit operating systems and ALL have updated to 10.5 and THEY ALL work fine. this is FOUR 64 bit systems ALL updated w/10.5 that work and ONE that is a 32 bit that will not. Can't get any help from apple. their suppot *****! I want to get someone on the **** phone or a live chat but cant. *** APPLE????? please let mw know if you find SOMETHING i can try next. I'm out of ideas and patience!

  • Why does Firefox switch focus to an immediately adjacent tab (in a series of tabs) on middle-clicking a link instead of staying on the same tab? (with setting of NOT switching to new tab).

    I have usually 4 tabs open by default. If, for example, I'm in the first tab and middle-click a link to open a new tab, the tab opens but firefox focuses on the tab immediately adjacent to the tab I'm on (in this case, from tab 1 to tab 2 instead of staying on tab 1 whilst tab 5 is loading). The pattern repeats if I'm on tab x and open a new tab from tab x, but focus shifts to tab (x+1) instead of staying on tab x.
    It happens more often than not, i.e. it sometimes stops but usually happens.
    I have this setup for a year now and this is the first time this is happening. I believe since this latest update of 3.6.13.

    This issue can be caused by an extension or plugin that isn't working properly.
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]
    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")

  • Setting focus to a JTextArea using tab

    Hi,
    I have a JPanel with a lot of controls on it. When I press tab I want to
    move focus to the next focusable component. This works fine for
    JTextFields, but when the next component is a JTextArea in a
    JScrollPane then I have to press tab 3 times to set the focus to the
    JTextArea. After pressing the tab key once I think the focus is set to
    the scrollBars of the JTextArea because when I press the up and down
    arrows the textarea is scrolled.
    How can I stop the JScrollPane from getting the focus?
    I have tried to set focusable to false on the scrollPane:
    scrollPanel.setFocusable(false);
    and the scrollBars of the scrollPane:
    scrollPanel.getHorizontalScrollBar().setFocusable(false);
    scrollPanel.getVerticalScrollBar().setFocusable(false);
    But it dosen�t work. Is this a completely wrong way of doing it?
    Please help!
    I use jdk 1.4.1
    :-)Lisa

    Not sure what your problem is. The default behaviour is for focus to go directly to the JTextArea.
    import java.awt.*;
    import javax.swing.*;
    public class Test1 extends JFrame
         public Test1()
              getContentPane().add( new JTextField("focus is here"), BorderLayout.NORTH );
              getContentPane().add( new JButton("Button1") );
              getContentPane().add( new JScrollPane( new JTextArea(5, 30) ), BorderLayout.SOUTH );
         public static void main(String[] args)
              Test1 frame = new Test1();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
    }

  • Webdynpro component in new tab.

    Hi Experts,
    I am tring to add a new tab in the struture level of a Project .
    I successfully added a new tab and created a webdynpro component for the Tab as well .
    However, when i see in the application , the tab does not show the created component. When right click and check the detail, it still shows the component DPR_MAINFRAME / DPR_PROJECTS_STRUCTUR . Kndly advice.
    Thanks,
    Siva.

    Hi
    Use this table  DPR_CUST_TABC to register your component to WD framework.
    Regards
    Praveen

  • Set Firefox to open a new tab without selecting it from the context menu by two-finger tapping in Lion

    In Snow Leopard, I had somehow set the two finger tap to open a new tab either from a link on a page or from my bookmarks bar, without having to select "Open a new tab" from the context menu. I recently upgraded to Lion and I can't remember how I set this feature-- or is it just not available anymore?

    There is a plugin for this and you can configure it as shown in the attached screen to open all links from the web page in a new tab by just clicking on it and not having to follow the native steps
    Link: [https://addons.mozilla.org/en-US/firefox/addon/open-link-in-new-tab/ Open Link in New Tab]
    Regards,
    Shoeb Surya
    <i>[link removed by Moderator]</i>

  • How do i set search to open in new tab?

    When I do a "google search" I want it to open in a new tab...how do I set that?

    Which search do you mean?
    *searching via the location bar (pref: keyword.URL)
    *search bar on the Navigation Toolbar
    *search bar on the about:home page (pref: browser.search.defaultenginename)
    *other search bar (e.g. added by extension)
    For the search bar on the Navigation Toolbar you can set the Boolean pref <b>browser.search.openintab</b> to <i>true</i> on the <b>about:config</b> page.
    You can also middle-click the search button or menu entry or use Alt+Enter to open the results in a new tab.
    For the Google website you can set that via the Google Search Settings page.

  • How do i set firefox to open a new tab with a specified web page..?

    Ive just installed firefox 5, and when i open a new tab, it open with a blank page. My previous version of firefox opened with my most visited pages as thumbnails. Can i revert to this setup, or can i set firefox 5 to open a new tab with a specified web page e.g google news...?

    No this isnt the problem. I want it to open a new tab with Google Search page and not with the big showcase of all my other pages.

  • How do I set the page that a new tab opens to?

    When I open a new tab, the tab opens automatically to Bing or some search engine other than what I have set as my home page which is set to Google. How do I get a new tab to open to my homepage and not something else?

    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
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Set Focus target when Add New Instance

    [LC Designer ES2 9.0] Using Action Builder to add a new instance of subform SITE, where first field is called SiteName.
    If I set action to Set Focus to SiteName, the focus goes to the *original* SiteName field instead of to the new instance.
    Users will typically add a number of additional sites and, each time, I want the focus to be set on the first field of the newest instance, not the original instance. How do I accomplish that? Thanks!           ~Carol

    I understand the concept (I think...), but am not clear on where to place the code.
    I used Action Builder to create an AddSite action: when check box chkAddSite is checked | Add a new instance of subformSiteInfo | and set visibility of subformSiteInfo to visible. Does your code go in that same action sequence? If so, what is the next Action Builder result selection? If not, where do I insert it?
    I never know whether the new instance of the subform will begin on the following page, so the user might keep clicking the chkAddSite box, thinking it didn't work. Although, thinking this through, maybe I could force the new subform instance to always appear at the top of the following page, and somehow direct the focus there, rather than to the specific first field???
    Thanks!         ~Carol

  • How to set homepage to open in new tabs

    Since new Firefox 5, I have lost the add-on that sets my homepage (google) to open when I open a new tab. I really want this back. I have looked thru the add-on list and haven't found anything. Is there another way to do this?

    You can modify Firefox with and extension, I personally would not want that at all, before dismissing a tab I make sure there is nothing in the tab in a backward direction, and the and would consider looking a anything but a blank page for a new tab as a distracting encumbrance but you can do what you ask for with the following:
    *NewTabURL :: Add-ons for Firefox<br>https://addons.mozilla.org/firefox/addon/newtaburl/
    I have three pages on my own on tabs
    * Tabbed Browsing in Firefox<br>http://dmcritchie.mvps.org/firefox/tabs.htm
    * Tabs configuration, extracted from About:config entries - MozillaZine Knowledge Base<br>http://dmcritchie.mvps.org/firefox/tabs_config.htm
    * 001 Tab Capacity and other Tests<br>http://dmcritchie.mvps.org/firefox/tab_capacity/001_with_underscore.htm
    I also like to change the styling on tabs and other chrome aspects of Firefox
    * [http://kb.mozillazine.org/User:Dmcritchie Styles & Extensions] that I use, see [http://kb.mozillazine.org/User:Dmcritchie picture] (Red borders -- active tab, Blue borders -- tab has been read, Green borders -- tab has not been read, Magenta borders -- tab is being downloaded)

  • Howcan I set the home page for new tabs?

    When I open a new tab, it opens up as a blank page. How do I setup Firefox so that the new tabs open in my home page?
    ''locked by a moderator due to age and that Firefox 13 has a new feature for a new tab''

    Thanks, but the problem I'm trying to solve is to get my home page to open automatically when I am already in Firefox and click on the new tab "+" sign to the right of my most recent tab. I have not found a solution to this in the link "How to set the home page" nor in the various help pages on new tabs.

  • How to set default web address for new tab

    Hi,
    i am using your browser from last 1 year, and i like to use it.From last week i found a problem that when i open a new tab in same window it by default start babylon search and i want it blank only, can you help me?

    If it is a search engine in the search bar, see the [https://support.mozilla.com/en-US/kb/Search%20bar Search bar] article for details of how to remove a search engine.
    If you have the Babylon Toolbar, follow the procedure in the [https://support.mozilla.com/en-US/kb/Uninstalling%20add-ons Uninstalling add-ons] article, in particular the section on uninstalling extensions and themes

  • How to set focus on component guaranteed?

    Hi All,
    I want to run my swing based application on win NT OS with JDK1.5. Now i need to set focus on my JFrame window (this is my requirement) but smetime it focussed and sometime it fails. So i need some guaranteed solution or approach so that it focus on my JFrame window i tried so many methods like requestFocusInWindow(),
    requestFocus(),setFocusable() etc. But my application sometime doing expected behavior and sometime fails.
    Can anybody suggest me 100% guaranteed approach? I appriciate any ideas.
    Regards,
    Pradeep
    Edited by: pradeep_dubey on Mar 17, 2009 6:52 AM

    But my application sometime doing expected behavior and sometime fails.Almost certainly a concurrency issue. Are you aware of Swing's single threaded rule, and have you taken care to create and update all Swing components on the EDT?
    [_Threads and Swing_|http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html]
    [_The Last Word in Swing Threads_|http://java.sun.com/products/jfc/tsc/articles/threads/threads3.html]
    db

Maybe you are looking for