Changing tab order of JTextfield

hi,
in my below code i've four textfields and i want to change the tab order of those textfields. i tried setNextFocusableComponent() but getting error on using this method. So plz tell me how it cud b done?
the error is: demo.java uses or overrides a deprecated API.
Recompile with -deprecation for details.
if ne body knows the meaning of this error & how to recompile with -deprecation plz tell me
import javax.swing.*;
import java.awt.*;
public class demo
public static void main(String args[])
JFrame f = new JFrame("Demo");
f.setSize(640,480);
f.setLayout(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextField a = new JTextField(10);
JTextField b = new JTextField(10);
JTextField c = new JTextField(10);
JTextField d = new JTextField(10);
a.setBounds(100,100,100,25);
b.setBounds(100,150,100,25);
c.setBounds(200,100,100,25);
d.setBounds(200,150,100,25);
f.getContentPane().add(a);
f.getContentPane().add(b);
f.getContentPane().add(c);
f.getContentPane().add(d);
// on adding these lines m gettin' error...
a.setNextFocusableComponent(c);
c.setNextFocusableComponent(b);
b.setNextFocusableComponent(c);
c.setNextFocusableComponent(a);
f.show();
}

This is all you need to understand to get going --
-- the Component returned by the method getComponentAfter (...) will get the focus on pressing Tab
-- the Component returned by the method getComponentBefore (...) will get the focus on pressing Shift+Tab
-- the Component returned by the method getDefaultComponent (...) will get the focus when the parent panel is displayed
Try to understand this Really Bad Example, then apply what you have understood to the sample you downloaded, which uses a Vector to store a list of Components and returns the next/previous Component for get..Before and get..After, wrapping around from the last to the first element and vice versa; also returns the first/last element for getFirst... and getLast... and the first element for getDefault...
Run this code and navigate by Tab or Shift-Tab, then uncomment the line I marked and try again. You'll understand.package ashwin;
import java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
public class ReallyBadExample extends JFrame {
    private JPanel nyPanel;
    private JTextField myTextField1, myTextField2, myTextField3;
    private static MyFocusTraversalPolicy myFocusTraversalPolicy;
    public ReallyBadExample () {
        setLayout (new GridLayout (0,1));
        setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        myTextField1 = new JTextField ();
        add (myTextField1);
        myTextField2 = new JTextField ();
        add (myTextField2);
        myTextField3 = new JTextField ();
        add (myTextField3);
        myFocusTraversalPolicy = new MyFocusTraversalPolicy ();
        // Uncomment the next line and see the difference
        //setFocusTraversalPolicy (myFocusTraversalPolicy);
        pack ();
        setVisible (true);
    class MyFocusTraversalPolicy extends FocusTraversalPolicy {
        public Component getComponentAfter (Container aContainer, Component aComponent) {
            if (aComponent == myTextField1) {
                return myTextField3;
            } else if (aComponent == myTextField2) {
                return myTextField1;
            } else return myTextField2;
        public Component getComponentBefore (Container aContainer, Component aComponent) {
            if (aComponent == myTextField1) {
                return myTextField2;
            } else if (aComponent == myTextField2) {
                return myTextField3;
            } else return myTextField1;
        public Component getFirstComponent (Container aContainer) {
            return myTextField2;
        public Component getLastComponent (Container aContainer) {
            return myTextField2;
        public Component getDefaultComponent (Container aContainer) {
            return myTextField2;
    public static void main (String[] args) {
        SwingUtilities.invokeLater (new Runnable () {
            public void run () {
                try {
                    new ReallyBadExample ();
                } catch (Exception ex) {
                    ex.printStackTrace ();
                    System.exit (1);
}db

Similar Messages

  • Control Click to Change Tab Order

    I know there are new ways to move the field names around to change form fields, but I miss the ability to change tab order by control clicking on the field. I like the new ones, but would like to have the old way also.

    You can get the coordinates of the mouse "drop" relative to the scene in the onDragDropped handler with
    event.getSceneX() and event.getSceneY().
    You can get the location of the top left of a node relative to the scene with
    private Point2D getSceneLocation(Node node) {
         if (node.getScene() == null) {
              return new Point2D(0,0);
         double x = 0 ;
         double y = 0 ;
         for (Node n = node ; n != null; n=n.getParent()) {
              Bounds boundsInParent = n.getBoundsInParent();
              x += boundsInParent.getMinX();
              y += boundsInParent.getMinY();
         return new Point2D(x, y);
    (and you can get the other corners of the node simply by adding the width and/or height from node.getBoundsInLocal() to the result of that if you need.)
    So if you ensure every tab has a graphic, you can iterate through the tabs and do something like
    int dropIndex = 0 ;
    for (Tab tab : tabPane.getTabs()) {
         Point2D tabLocationInScene = getSceneLocation(tab.getGraphic());
         if (tabLocationInScene.getX() > event.getSceneX()) {
              break ;
         } else {
              dropIndex++ ;
    tabPane.getTabs().add(dropIndex, tabToBeAdded);
    Ensuring every tab has a graphic probably just means setting the text to an empty string and setting the graphic to a Label containing the text; or I guess you could just use a zero width and height Rectangle, or some such.

  • Changing tab order

    I have created a generic form and then used it as the base for my custom forms.  I had used radio buttons on one section and realized that is not the correct format so I changed them to check boxes.  When I made the change it completely messed up the tab order even though all I did was change the format from radio to check box.  Any ideas why this happened and how to prevent it?  I have 90 custom applications that now have to be changed and fixing the tab order is taking forever.  Any help is greatly appreciated.

    You can rearrange the Tabbing Order through the Tab Order pallete. Did you try that?
    Tab Order pallete can be opened from Window menu
    Nith

  • Changing tab order in Acrobat XI

    Is there a way to get Acrobat XI to change the tab order by clicking the field like we did in older versions? I've had good luck using sort by row, but the form I'm working on now isn't sorting by row correctly.
    Thanks for the help!!
    Ken K. - 2191  

    Thanks Gilad.  I'm getting used to the newer way of ordering tabs.

  • Control/change tab order

    How does one control the tab order (the order in which controls are visited when the TAB key is pressed) in a JavaFX 1.3.1 application?
    It isn't always the case that one wants the tab order to be the same order as used in the layout.

    Thanks a lot for your help guys.
    Let me explain a little bit more my problem, maybe you guys get a good way to do this.
    Ok, I have a tab control with 4 tabs (Auto Mode, Manual Mode, Troubleshooting and Configuration) in that order. In the "Auto Mode and Manual Mode tabs I have a selector switch to select the operation mode (auto or manual). Now, when I have the switch in auto mode, the manual mode tab page is hidden, when I change the selector switch to manual mode the manual mode tab page is unhide, the auto mode tab page is hide and the manual mode tab page is automatically selected. This happens because my manual mode page is the second one and when the page before is hidden the next one get active. The problem came up when I change the switch back to manual mode. I want that the auto mode page unhide, the manual mode page hide and the auto mode page get active, but instead the page that came active is the troubleshooting page since this is the one after the manual mode page.
    So, what I was planning to do was to rearrange the pages order when auto or manual mode are selected so that the second page be always the hidden one.
    Maybe I confuse you guys more, but that'sthe idea. If something came out of your mind, I really appreciate the help.
    Ferdinand Martinez
    FMO Automation LLC

  • Portfolio Item - Change tab order

    Hello Everybody
    I want to know how is possible to change the order of the Item tabs ?
    For Example, If I want to display the tab "Phases and Decisions" in first position before the "Overview" one, what must I do for this result ?
    Thanks for your help
    Rémy

    Hi,
    I think you can do it in  this path :
    Transaction SE80 -->Package RPM_UI_WD -->Webynpro --> ApPlication Component -->RPM_ITEM_DETAILS_CFG --> Start configurator --> Change --> Component Configurator --> Variant RIH_CREATE --> here you can see the views and each view has a sequence Index.
    Regards,
    Sara

  • Changing Tab order in a completed form without altering or moving fields here and there

    Hi All,
    I've made a complex questionairre and is almost complete. Now the problem is that when I converted this file from Word, many fields were automatically detected and their tab order/ numbering was set by Acrobat itself. The remaining fields in the form (at different places) were created by myself. Now in the tab ordering, the fields automatically detected have priority and the fields I created, are much different from the corresponding fields in tab numbering. For your understanding, I'm including the screenshot too. Please see the tab numbering in the image and after field # 7, there is field # 28, then field # 26, and then field # 29 which is not the way it should be.
    Please advise any solution (if there is any) on your earliest convenience.
    Thanks in anticipation!

    Have you opened the "Pages" navigation panel and looked at the options for the page?
    There should be a series of options like "Row", "Column" or "Unspecified". Select the "Row" and see if the form tabs the way you would like.

  • Changing tabs order in the JTabbedPane (DnD)

    Hi,
    I have a JTabbePane with different tabs in it and I want to be able to drag one tab and insert between other two with the mouse. Kind of like you can reorder sheet tabs in MS Excel. Does any one have an idea how this behavior may be implemented?
    Thanks a lot,
    Ilya

    Thanks for this idea. I misunderstood what you meant until Jeremy responded saying you were �right on the money�. I thought you meant that putting another plot in the array but making it transparent was going to help somehow, but now I understand that you mean plotting the �up front� data to a separate XY graph indicator which is transparent and overlaying the original XY graph. I may wind-up doing this. I�m just not excited about linking all the scaling info from one graph to the scaling of the transparent graph and creating the necessary event handling so that when the user scales one graph or changes the auto-scaling, the other graph�s scales gets updated, but perhaps it�s the only way. Thanks again for your input.

  • How to set Tab ordering in JPanel

    hi all
    i add a JPanel on a JFrame and Various swing Controls on that JPanel. now i want to change tab ordering of components present in my JPanel.
    please guide me how can i do this. i have tried setFocusTraversalPolicy but it does not work with JPanel.

    You should read the article from Sun:
    "How to Use the Focus Subsystem"
    http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html
    Moshe

  • You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You can use the Menu Editor add-on to rearrange or remove menu items - https://addons.mozilla.org/firefox/addon/menu-editor

  • How do I change the order of open tabs?

    I currently have approximately a dozen tabs open, of which most are required to be viewed in a particular order. Is there a way to change the order of these tabs? If there is not, holding onto one of the tabs without sliding it sideways could become a method of "unlocking" the selected tab, allowing it to be moved up or down the list (I sure think it sounds like a good, and mostly easy, possible future addition to the app).
    Thanks for your time,
    Adam

    Adam, unfortunately at this time this is not a feature of Firefox for Android. To move the tabs you would have to close it out and open them in the order you wanted them to appear.
    If this is a desired feature however, I would recommend leaving feedback about this in input.mozilla.org.

  • How to change the order of the tabs in featured news?

    Hi,
      I use the 'Featured News' widget on my company website and it has 10 tabs. The newest item is at the top but when I add a new tab it goes to the bottom and I can find no way of changing the order of the tabs so that everytime I add new news I have to copy each tab and it's content down one place in order to get an empty tab at the top to put the new news item in. This takes an unneccesssarily long period of time. Can someone please let me know if there is an easy way to change the order of the tabs?
      Thanks very much ;0)
            Justine

    Just click on the title tab until it is isolated (one click before the text is highlighted) and move the tab to the position you want.
    Thanks for your reply. I've done this in the past but found that the position of the tab in terms of it's place in the hierachy doesn't change so if I move the top tab down one, the way you've described and then upload the page I find that the second tab down (which was the first previously) displays first. How can I change the 'position of the tabs interms of their hierachy in the widget?
      Thanks again
         J

  • How do I delete a field that's Tab 0 or change field order?

    I created a fillable form in Acrobat 10 Pro. Some of the fields became Tab 0 and they don't show up when viewing tab order, and also those fields can't be changed or deleted.  The fields were originally set up as distinct data entry fields with specific names.  I don't know how they changed from their original field properties (i.e., state, zip code, etc.).  When I opened the document to continue my set-up the tab 0 fields which had previous taken on the field name Start Work were now titled Middle Name/Initial, yet another field in use that works properly.
    I've already done all the reinstall/repair and PC based troubleshooting/malware removal but these issues persist. 
    Any help in diagnosing what happened and how I can remedy this strange occurrence would be much appreciated.

    I like the redaction tool idea as a workaround.  That will make life a good deal easier so I can do the more permanent fix when I have more time on my hands.  Thanks GIlad.
    Anne
    Update - Good news is once those fields are minimized and moved off the visible page, they disappear.  Unfortunately redaction doesn't work as the only way to view those fields was when in form editing mode.  Also couldn't remove hidden information as those fields don't show up in the field list, either.  For now they are just sitting as tiny spots in a corner on each page where they existed.  And the finished product looks and works as it should. . . .

  • How to change the tabbing order of an array of clusters?

    How to change the tabbing order of an array of clusters?  I have the cluster arranged in table in the front panel.   The cluster element goes horizontal and array element goes vertically.   When I press the tab key, the cursor goes to the next array element instead of the next cluster item (down instead across).
    Solved!
    Go to Solution.

    Broken Arrow wrote:
    Harold asked a perfectly reasonable and necessary question, but how is that a Solution ???
    I believe it is called the Socratic Method.
    Sea-Story time
    I had the privledge of working for Ron Davis when he managed the Allegheny District of DEC. He was an ex-WO4 (Highest possilbe rank for non-commisioned officer in US Navy, required act of congress to confirm).
    Ron never answered any question I ever saw presented to him. I remember a group of managers in a frenzy over some issue  running to him to to see what he thought. He asked them a series of questions that lead them to the solution and soon they were smiling and slapping each other on the back as they walked away.
    Who is that has a signature that read "it is the questions that guide us"?
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Can you change the tab order in Muse forms?

    Can you change the tab order in Muse forms?

    Hi Rebecca,
    By tabs do you mean the form fields? If yes, then you can simply rearrange them by repositioning the other fields using mouse.
    However, the e-mails that are received on submission of the forms show the original sequence of the fields.
    Regards,
    Neha

Maybe you are looking for

  • Unable to print to office jet pro 8600 over wifi from a laptop running vista, basic home edition

    Have a new officejet 8600 pro and am able to print via wifi from laptop running windows 7 and hp touchpad running webos, so all is working fine. However, I am unable to print via wifi from a laptop running Vista Home Basic, 32 bit OS. I can see the p

  • Format Issue

    I have a hbox that has a repeater of linkbuttons, and the datasource of the repeater is an array collection I build. I first build it from 1 to 10 (1 2 3 4 5 6 7 8 9 10), and to the right of the repeater I put an image that filters my numbers to give

  • Problem with download via Adobe Download Assistant

    Hey! I want donwload Adobe After Effects trial but i can't download anything! Where should be list of products (Products you may like) there is noting, empty field. Why? Can someone help me fix this?

  • Static IP for Mac OS 10.5 -- Help!

    I'm not sure how to set up an static IP for my macbook. It will be using my airport, not my built in ethernet. Can someone provide me a step by step guide? I'm lost. Thanks!

  • Kadb panic error in solaris

    Hello, Iam useing kadb debugger for solaris on Intel platform. I enabled kadb by giving the following option: b kadb -d After this it enters into an interactive setup. I pressed BACK SPACE followed by an filename to debug. Actually i specified the ex