Changing the application wide default focus traversal policy

Hi,
I have a Swing application built using JDK1.3 where there lots of screens (frames, dialogs with complex screens - panels, tables, tabbed panes etc), in some screens layouts have been used and in other screens instead of any layout, absolute positions and sizes of the controls have been specified.
In some screens setNextFocusableComponent() methods for some components have been called at some other places default focus traversal is used. (which I think is the order in which the components are placed and their postions etc). Focus traversal in each screen works fine.
Now I have to migrate to JDK1.4. Problem now is that after migrating to JDK1.4.2, focus traversal has become a headache. In some screens there is no focus traversal and in some there is it is not what I wanted.
So I thought to replace applicaiton wide default focus traversal policy and I did the following:
///////// Replace default focus traversal policy
java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new java.awt.ContainerOrderFocusTraversalPolicy());
But there is no change in the behaviour.
Then I tried following:
///////// Replace default focus traversal policy
java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new java.awt.DefaultFocusTraversalPolicy());
I did all this in the main() method of the application before anything else just to ensure that all the components get added after this policy has been set. But no luck.
Does someone has any idea what is the problem here ? I do not want to define my own focus traversal policy for each screen that I use (because thats lot of codes).
Thanks

not that hard if you only have the one focus cycle ( > 1 cycle and it gets a bit harder, sometimes stranger)
import javax.swing.*;
import java.awt.*;
class Testing
  int focusNumber = 0;
  public void buildGUI()
    JTextField[] tf = new JTextField[10];
    JPanel p = new JPanel(new GridLayout(5,2));
    for(int x = 0, y = tf.length; x < y; x++)
      tf[x] = new JTextField(5);
      p.add(tf[x]);
    final JTextField[] focusList = new JTextField[]{tf[1],tf[0],tf[3],tf[2],tf[5],tf[4],tf[7],tf[6],tf[9],tf[8]};
    JFrame f = new JFrame();
    f.setFocusTraversalPolicy(new FocusTraversalPolicy(){
      public Component getComponentAfter(Container focusCycleRoot,Component aComponent)
        focusNumber = (focusNumber+1) % focusList.length;
        return focusList[focusNumber];
      public Component getComponentBefore(Container focusCycleRoot,Component aComponent)
        focusNumber = (focusList.length+focusNumber-1) % focusList.length;
        return focusList[focusNumber];
      public Component getDefaultComponent(Container focusCycleRoot){return focusList[0];}
      public Component getLastComponent(Container focusCycleRoot){return focusList[focusList.length-1];}
      public Component getFirstComponent(Container focusCycleRoot){return focusList[0];}
    f.getContentPane().add(p);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  public static void main(String[] args)
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        new Testing().buildGUI();
}

Similar Messages

  • Changing the first item being focused in a window

    Hello fellow programmers. I'm developing an application that contains a number of radio buttons as well as a PLAY and STOP button. I would like the PLAY button to be focused whenever the window is opened. I was able to get this done by calling the requestFocusInWindow() method after the initComponents() method in my form class. I also had to call the requestFocusInWindow() method in the STOP button's ActionPerformed method. I noticed for a split second, another button was getting the focus whenever the STOP button was pressed (until the requestFocusInWindow()) was called).
    I've tried adding the requestFocusInWindow() method in just about every location in the PLAY button's code with no success. The only thing that works is what I described. Is there a better way of accomplishing this?
    Thanks in advance.

    You'll need a custom focus traversal policy, see [the tutorial|http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#customFocusTraversal].

  • Changing the application that a file type opens with

    I have MSFT Excel and Subethaedit installed...
    I want Subethaedit to open all "*.spad" files
    I go to "Get Info" then go to "Open with:" then choose Subethaedit
    Then I press "Change All...", a dialog pops up and asks if I want to apply the change to all documents of the form "*.spad", and I answer "continue" and then...
    It ignores me; it drops Subethaedit from the list of apps to "Open with" and doesn't change the default format.
    How do I force the type to change to the app I want? Is there a text-file I can munge somewhere?
    mac mini   Mac OS X (10.4.8)  

    Hi, thechao. Welcome to the Discussions.
    It's possible your launch services database is corrupted. See my "Resetting Launch Services" FAQ. Then try the procedure you defined earlier, which is also described in "Mac OS X 10.4 Help: Changing the application that opens a document."
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X
    Note: The information provided in the link(s) above is freely available. However, because I own The X Lab™, a commercial Web site to which some of these links point, the Apple Discussions Terms of Use require I include the following disclosure statement with this post:
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • How to change the application alias for a web project in NW7.2

    Hi,
    a simple question, but I could not manage to solve it: How do I change the application alias (the url) of a web project? I'm using Netweaver 7.2 and all the tutorials I found refer to earlier versions and do not work anymore.
    In particular, I would like to change e.g. "server.com/vendor~webbappname" (the standard url of the web project) to "server.com/mywebapp".
    Thanks in advance for your help!

    Hi,
    Try customizing the <context-root> element in the web.xml deployment descriptor, for example:
    <?xml version="1.0" encoding="ASCII"?>
    <application xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
              http://java.sun.com/xml/ns/javaee/application_5.xsd"
               version="5">
               <display-name>YourWebApp</display-name>
               <module>
                   <web>
                   <web-uri>YourWebApp.war</web-uri>
                   <context-root>mywebapp</context-root>
              </web>
         </module>
         <module>
              <ejb>YourWebAppEjb.jar</ejb>
         </module>
    </application>
    Afterwards, rebuild and redeploy your application.
    I hope that helps.
    Regards,
    Yordan

  • How to change the application title in apex while importing it ..

    Hi ,
    I have an issue here. As per the requirements I need to change the application title in Apex while
    importing it from One instance to another instance.
    Ex: My application title is WATERFALL PORTAL in iWATERFALL instance ,it must be changed to PUAT PORTAL if im Importing it to PUAT instance.
    This change has to be done Dynamically. Without Entering it Manually.
    Kindly help me out and Will be Great for your Assistance.
    Thanks,
    Vishal

    1001804 wrote:
    Hi ,Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your forum profile with a real handle instead of "1001804".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I have an issue here. As per the requirements I need to change the application title in Apex while
    importing it from One instance to another instance.Please clarify what you mean by "application title". The Application Name in the application definition? The displayed Logo in the user interface properties?
    Ex: My application title is WATERFALL PORTAL in iWATERFALL instance ,it must be changed to PUAT PORTAL if im Importing it to PUAT instance.
    This change has to be done Dynamically. Without Entering it Manually.Also clarify what you mean by "instance". An "APEX instance" refers to the APEX installation in a database. The "APEX instance" does not have a specific name property, and would therefore usually be referred to using the database name. Or do you mean the APEX workspace containing the application?

  • I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.Not working in USA timezone.

    I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works fine in our side (Timezone,kolkata ,india even for Timezone,slvaniya,USA) but our USA client is telling that on changing the date it not starts from start-up sequence.Can anyone plz suggest the reason for it.

    This is the code which we have used.
    //////////Return if it is first time for the day or not//////////////
    + (BOOL)isFirstTimeToday {
    BOOL result = YES;
    NSDate *now = [[NSDate alloc] init];     /// represents the current time
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: now];
    NSDate *today = [gregorian dateFromComponents:components];
    [now release];
    [gregorian release];
    NSDate *savedDate = [[NSUserDefaults standardUserDefaults] objectForKey:LAST_TIME_VISITED];
    if (savedDate) {
    if ([today earlierDate:savedDate] == today) {
    result = NO;
    return result;
    ////////Stores the date/////////////
    + (void)userDidVisitReenforceScreenToday {
    [[NSUserDefaults standardUserDefaults] setObject:[NSDate todayAtMidnight] forKey:LAST_TIME_VISITED];
    ////////////What [NSDate todayAtMidnight] stores/////////////////////
    + (NSDate *)daysFromNowAtMidnight:(NSInteger)nOfDays {
    NSDate *date = [NSDate dateWithTimeIntervalSinceNow: (86400*nOfDays)];
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: date];
    NSDate *dateAtMidnight = [gregorian dateFromComponents:components];
    [gregorian release];
    NSLog(@"dateAtMidnight : %@",dateAtMidnight);
    return dateAtMidnight;
    + (NSDate *)todayAtMidnight {
    return [self daysFromNowAtMidnight:0];
    Please Suggest..

  • I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works with iPod not with iPhone

    I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works with iPod not with iPhone

    Try posting in the developer forums to see if you can get some assistance,you'll have to be a registered developer for access though.
    developer.apple.com

  • Is it possible to change the system's default font?

    It is difficult to explain my question, but is it possible to change the system's default font of the script at the top of all windows, and desktop icons? I really think that would add personality to my powerbook. Thanks for any input.

    It is possible, and may be changed using the Terminal if you know the commands. However, the easier way is to use TinkerTool <http://www.bresink.com/osx/TinkerTool.html>.
    Enjoy!
    bd

  • Regarding changing the application settings for Financial management (BPM)

    Hi,
    I have built the sample Comma application in HFM 9.3.1 using the BPM functionality from workspace as outlined in the documentation. The consolidation rules are set to "N" for this application when I open the XML using the window client. Can anyone tell me how I can change this to "Y" through workspace and load the application again. Since its a BPM application it does not allow me to load from window client. How to modify the application properties of a Financial manegement application through workspace (BPM). Any help will be appreciated.
    Thanks in Advance......

    If you extract your application from the web using the extract tasks, check on the Financial Management Application format, this should provide you with a file with an app extension something like this:
    hfmmetada.app
    When you hit extract and then click on 1 Click here to download, then save, on the save as file type button, make sure is .app; then open your app file with a text editor, change the application settings for ConsolidationRules=N to Y.

  • How to change the application icon in 10g

    Dear all,
    how to change the application icon in forms 10g. i mean the icon which is located on the window it self.
    Best Regards,
    ShoooSh

    Hello,
    <p>Maybe you could find a solution in this article</p>
    Francois

  • Adobe acrobat pro x change the program's default page display to single page view - Windows 8, HP La

    adobe acrobat pro x change the program's default page display to single page view - Windows 8, HP Laptop

    Since there were no answers, I will take a stab at a reponse. For the 2nd method, I suspect you could simply select the print or press job options to get the desired results or turn off "use local fonts" in Acrobat. If you check the font list, the fonts are probably not embedded and that is likely the problem.
    I noticed that you have both Reader and Acrobat installed and that might cause some conflict, but should not be the issue here. If you were to uninstall Reader, you would have to repair Acrobat. The conflict here is that you might have problems with the one opening when you want the other. If it works for you, then don't worry about it.
    For technique 1, I suspect you may be using IE 9 that has apparently been a problem since it came out. I have refused to install it. However, it may simply be that PDF Maker does not work correctly with your browser, or got deactivated and needs to be allowed to run in your browser (IE I am assuming).

  • Changing the application switcher shortcut

    Hi,
    Can anyone help me find where or how to change the application switcher shortcut (command-tab).
    I'm using illustrator and I'm used to switching between my selection tools using command-tab. But now with OSX Leopard, every time I do that, it just switches applications.
    I've tried mac help and also have searched these forums but haven't found a similar request.
    Thanks.

    I've been looking everywhere for a way to change this, or at least disable the shortcut. I have the same problem, but with QuarkXPress. I know that the command originates from the Dock, so I bet there's a way to hack the Dock so it disbles the shortcut...

  • Changing the Application Parameter in the mass copied iviews

    Hi,
    I have copied the standard package iviews,pages,roles to a custom folder.Now I want to change the "Application Parameter" of the all copied iviews.Is it possible to do the mass change of a single parameter in all the copied iviews?
    If possible,please suggest how to achieve the same.
    Thanks,
    Rajani

    Hi,
    Yes, you can use the Multiple Property Replacement feature : [Multiple Property Replacement|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/0f/764b87dfb948fcb13fd7695e157892/frameset.htm].
    Regards,
    Pierre

  • Change the application builder's language

    Is there a way for developers to change the application builder's language?
    My location is in Germany but I prefer the american-english language during development; in case of normal usage of my Apex-Appl. (as a normal end user) I'd like the "german way"...

    Hello,
    If you look in the Oracle® Database Application Express Installation Guide, paragraph 4.7 :
    The Oracle Application Express interface is translated into German, Spanish, French, Italian, Japanese, Korean, Brazilian Portuguese, Simplified Chinese, and Traditional Chinese. A single instance of Oracle Application Express can be installed with one or more of these translated versions. At runtime, each user's Web browser language settings determine the specific language version.
    The translated version of Oracle Application Express should be loaded into a database that has a character set that supports the specific language. If you attempt to install a translated version of Oracle Application Express into a database that does not support the character encoding of the language, the installation may fail or the translated Oracle Application Express instance may appear corrupt when run. The database character set AL32UTF8 supports all the translated versions of Oracle Application Express.
    In the rest of the doc there is a description how to install other languages...
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    http://www.bloggingaboutoracle.org/
    http://www.logica.com/

  • Changing the Application class of script

    How can i change the application class of a script?

    Hi use TDOCLASS: object class.
    Hope this solves your issue.
    <REMOVED BY MODERATOR>
    Thanks,
    Dishant
    Edited by: Alvaro Tejada Galindo on Feb 6, 2008 2:33 PM

Maybe you are looking for

  • Uploading a CSV file and getting Error ORA-01403: no data found in V4.1.1.

    I have an issue where myself and another user are unable to upload a csv file to my application using the "File Browse" page item in V4.1.1. I get the following error, "Error ORA-01403: no data found". This function was working perfectly last week pr

  • My ipod touch 4g freezes on the apple logo and itunes doesnt recognize it

    my 4g ipod touch freezes on the boot logo and wont change. i tried to put it in restore mode but it just restarts. help

  • Linux Server Sizing

    Is there any documentation on server sizing? I have a client/server application that will have between 100 and 200 users (75-100 concurrent), and would like to go to a Linux platform. The app is currently running on a large HP server with other apps

  • AC Wall Charger not working

    Hi, This seemed to be the most appropriate place to post this... My AC wall charger has just stopped working all of a sudden. The ipod doesn't respond at all when connected to it (it was working fine for the last 7 months). Firstly, it is a firewire

  • Clean install - Slow Windows Networking

    I have done a clean install of 10.6 I can successfully login to my Windows 2003 server. But, the CONNECTING... takes an extremely long time, about 1 minute. If I reboot the 1st time I try to connect it goes very fast. Any other time it takes about 1