Setting a JTree renderer breaks the focus traversal order

Hello,
I am not sure what's wrong, but when I set a customize JTree renderer it breaks the focus traversal order of my UI. Can someone tell me what's wrong and also how to prevent it from changing the order of my components?
For instance, if I have component order 1, 2, 3, 4, 5 to begin with and after I call JTree.setCellRenderer(new SomeRenderer()), the order would change to something like this 1, 2, 4, 5, 3
To give you an overview of what I am creating, I am customizing a UI that will be plug into JFileChooser to replace the default UI. I know I can create my own FocusTraversalPolicy, but the thing is that I don't know some of my components ahead of time. As long as I can prevent the order change, I think it would be fixed.
Regards,
Soot

Try creating a Short, Self-Contained, Compileable, Executable
program which has this problem. Right now it would take a
mind-reader to solve your problem.

Similar Messages

  • Bug: setting ColumnChart type property breaks the chart object.

    PLease confirm if this Is this a bug or maybe ColumnChart
    type property is only applicable as MXML tag attribute?
    Description: Setting the
    type property of
    ColumnChart object other than "
    clustered" breaks the chart object. (i.e: series dissappear)
    Resetting to "clustered" wont restore the series.

    It breaks the chart when series have effects applied,
    otherwise it works fine.

  • While filling up the set uptables ran twice for the same sales order number

    Hi all,
    I ran the set up tables for a sales order number in the morning and then ran again in the evening by mistake so when i see in the rsa3 i can see 2 sales order number.
    If i load the same in the sales order header and item ods, will there be any duplicates from ecc to bi?
    Thanks
    Pooja

    Hello,
    If you load your ODS in overwrite mode, there should not be any problem.
    Regards,
    Fred

  • JApplet Focus Traversal 1.4

    I am writing a new JApplet and I am having problem with focus traversal.
    Hitting the tab key on Windows 2000 doesn't traverse through the
    components that are on the JApplet's contentpane. It happens with the 1.4
    appletviewer and with IE5.5 and IE6 using the 1.4 plugin. Below is the code and if I change
    it to extend Applet and add Buttons it works fine. Furthermore, if I run
    it as a standalone application (by extending JFrame) OR if I pop up an external JFrame from the applet it works fine. Is there something I missing?
    import javax.swing.*;
    import java.awt.*;
    public class AppletTest extends JApplet {
         public void init() {
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
              c.add(new JButton("button1"));
              c.add(new JButton("button2"));
              c.add(new JButton("button3"));          
         public void start() {
    Anthony

    Try this!
    As I found out that when I used the plugin with the show console option, the focus traversal worked fine. But when I changed this option to hide or don't start up, the focus traversal failed to work.
    So I tried to find out what the differences where. I found this. When the show console option
    is selected, the parent frame (provided by the browser) has a focus traversal policy named:
    javax.swing.LayoutFocusTraversalPolicy
    With both the other options this was the java.awt.DefaultFocusTraversalPolicy.
    This code will set the DefaultFocusTraversalPolicy to the javax.swing.LayoutFocusTraversalPolicy.
    After this everything works normal.
    Place this in the start of the init () method of JApplet
    Container parent = this.getParent ();
    while (!(parent instanceof Window) && parent != null)
    parent= parent.getParent ();
    if (parent != null)
    parent.setFocusTraversalPolicy (new javax.swing.LayoutFocusTraversalPolicy ());

  • JavaFx Adding Focus Traversable Keys.  Any Ideas?

    Hallo,
    Since there is currently now way to add other keys to the focus traversable list, I have to create my own method of doing it.  What I want to do is have a single scene, and in that scene I want the enter key to behave  
    the same as a tab key.  But there are a lot of Buttons, TextField, ChoiceBoxes etc.  Therefore Pressing enter key must take me to the next focusable item.  I have really been struggling to find a method that work.  I am really stuck.  Some help would be much appreciated.
    Thank you

    Well there are a few things you can do imo.
    1.  Create KeyEvents for each of your controls.
    2. http://download.java.net/jdk8/jfxdocs/index.html? click Scene, then NODE(for some reason the HTML links do not appear, and the one I had was for "SHAPE 3D").
    focusedpublic final ReadOnlyBooleanProperty focusedPropertyIndicates whether this Node currently has the input focus. To have the input focus, a node must be the Scene's focus owner, and the scene must be in a Stage that is visible and active. See requestFocus() for more information.
    See Also:
    isFocused(), setFocused(boolean)
    Default value:
    false
    focusTraversablepublic final BooleanProperty focusTraversablePropertySpecifies whether this Node should be a part of focus traversal cycle. When this property is true focus can be moved to this Node and from this Node using regular focus traversal keys. On a desktop such keys are usually TAB for moving focus forward andSHIFT+TAB for moving focus backward. When a Scene is created, the system gives focus to a Node whose focusTraversable variable is true and that is eligible to receive the focus, unless the focus had been set explicitly via a call to requestFocus().
    See Also:
    isFocusTraversable(), setFocusTraversable(boolean)
    Default value:
    false
    If you click either property it will brng you to the entire 8000 lines of the code, which I also cannot link for some reason.
    Both will link you to the area of code, and possibly you could edit this yourself.

  • Process Order Batch number generation at the time of order creation

    Dear All,
    I m facing some issue at the time process order creation:
    Current Settings:
    1. Batch Number Creation at the time of order create.
    Reason for this setting: Release of order is done  by releasing operations one by one, therfore batch number will be generated on the final operation release, thats why we set up batch creation at the time of order create.
    2. For FG batch number generation there is a program that copy the SFG(in Order BOM) Batch number to FG. ITs a industry requirement.
    Problem:
    when we create FG order system generate the error message at the time of order creation tht No batch could be determine.
    Please suggest the solution
    Thanks,

    Hi
    Hope you have cretaed Batch serch strategy in COB1
    U need to maintain it as per your strategy type.

  • Can someone explain how to set the focus to a component

    Hello,
    What is the best way to ensure that a component gets the focus with code. I have tried requestFocus and requestFocusInWindow and none of them seems to do there work. The frame containing the components that should get the focus is displayed, the component is focusable so that is not the problem. What I found out is that if the component is deep in a nesting of panes (where the top pane is in the frame) is that calling requestFocus or requestFocusInWindow does not give the component where this focus is called on the focus but either the pane that contains it, one of the parent panes of this pane or one of the components in these panes, in almost all cases the component requesting the focus does not get the focus at all. I always have to write a work around in defining a focus listener for all these panes that transfer the focus back to the component that requested the focus originally, I can't believe that this is the way to ensure that a component has the focus via code. I have searched for documentation but found nothing on what requestFocus(inWindow) is actually dooing (a lot about focus traversibility but I don't want to control this, just make sure that a component gets the focus).
    Again I'm pretty sure that the toplevel window is activated and that the component that requested the focus is focusable (I had created a derived version of the DefaultFocusManager that showed who has focus). Personally I think (and I'm not alone if you do a search in this forum on focus management) that there is either a big problem in the documentation of focus management or that it is still not possible to even try to set the focus on a component in a easy way.
    Marc

    Hello,
    thanks for your reply, here is some example code that illustrates the problem I have (the actual code is to big to show here, which is the raison why I did not posted it here). The code wil create a frame with a JPanel with a JTextField, a 'New' Jbutton and a 'Delete' Jbutton, a tabbed pane in the center ('New' will create a new JPanel, add it to the tabbed pane and set the focus on it, either by calling RequestFocusInWindow() directly or by calling it via InvokeLater (someone on this forum suggested to use this). I changed also the focusmanager to show the component that has the focus when you type something. To test compile and run the program (either with a call to requesteFocusInWindow directly or indirectly (by changing the comments), on my system I get the following behaviour:
    1. requestFocusInWindow called directly
    Start program en type, the tabbed pane has the focus
    Press New and type something, a button has the focus not the created panel
    Press New again and type something, a button has the focus not the created panel
    2. requestFocusInWindow be called indirectly
    Start program and type, the tabbed pane has the focus
    Press New and type, the created panel has the focus (I thought at one moment that I had found the solution there, but alas ...)
    Press New again and type something, a button has again the focus.
    Note that with my real program it is not always a button that will have the focus, sometimes it is a combobox or a TextField (I tried to get this with the example code (the JTextField) but did not succeed.
    Hopes this clarify the problem a little bid, what I want is when the window is visible to set focus on newly created panes (or in the real program on the panel that is selected via the tabbed pane or via a key combination to shift the focus between the panels) but requestFocusInWindow seems to behave unpredicatable. I can't imagine that what I see is a bug so I must make some assumptions which are not valid but I don't see them, btw listening on the WindowListener is I think not the solution because the frame is already displayed when I want to set the focus and I do not use a modal dialog box.
    The example code follows here
    Marc
    * Main.java
    * Created on December 21, 2004, 8:58 AM
    package testfocus;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * @author marc
    public class Main
    static int counter;
    /** Creates a new instance of Main */
    public Main()
    * @param args the command line arguments
    public static void main(String[] args)
    JFrame frm=new JFrame();
    JPanel content=new JPanel();
    frm.setContentPane(content);
    final JTabbedPane paneContainer=new JTabbedPane();
    JPanel bar=new JPanel();
    JButton create=new JButton(new AbstractAction("New")
    public void actionPerformed(ActionEvent ev)
    counter++;
    final JPanel pnl=new JPanel();
    pnl.setName("test"+counter);
    paneContainer.add(pnl);
    pnl.setFocusable(true);
    pnl.requestFocusInWindow();
    /* Either use this or the previous line
    SwingUtilities.invokeLater(new Runnable()
    public void run()
    pnl.requestFocusInWindow();
    JButton delete=new JButton(new AbstractAction("Delete")
    public void actionPerformed(ActionEvent ev)
    int i=paneContainer.getComponentCount()-1;
    if (i>=0)
    paneContainer.remove(i);
    JTextField dummy=new JTextField("Test");
    bar.add(dummy);
    bar.add(create);
    bar.add(delete);
    content.setLayout(new BorderLayout());
    content.add(bar,BorderLayout.SOUTH);
    content.add(paneContainer,BorderLayout.CENTER);
    frm.setSize(300,400);
    FocusManager.setCurrentManager(new DefaultFocusManager()
    public void processKeyEvent(Component component,KeyEvent ev)
    System.out.println("Focus owner"+getFocusOwner());
    super.processKeyEvent(component,ev);
    frm.setVisible(true);
    }

  • 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();
    }

  • How can I set the focus to a field on a Portal form?

    Can anyone tell me if it is possible to set the focus to a particular field on a form which was created in Portal and is based on a PL/SQL procedure?
    The form contains a mixture of field types and also takes parameters from another form and displyas them.
    I have managed to set the focus on a form which is defined dirdctly in a PL/SQL procedure, using Javascript, but this doesn't seem to work for a Portal form.

    Hi,
    look at the discussion on May 25:th 2001, subject "How to get the cursor into a specific field", it might give you an idea.
    To give you some hint right now:
    In the "Additional PL/SQL Code" tab, "Before displaying the page", add following code:
    htp.p('<BODY onLoad="document.forms[0].elements[6].focus();">');
    forms[0] if you only have 1 form, and elements[the number of the item you want to be in focus]
    I hope this could help you
    /Sara

  • Setting focus outside a control when no other control can get the focus

    Hello
    I'd like to know if there is a way to setfocus outside of a control even if there is no other control to receive the focus.
    I have an editbox that has the focus (active) and I want to set visible to false to this control., but I cannot since it has the focus and there is no other controls that can get the focus.
    As a temporary measure I've added another editbox that I moved outside of the visible interface to which I've moved the focus. But I would like to know the proper way to do this.
    Thank you for your help.

    I think you are asking how to bring a windows form to the front.
    If not I apologize...
    The way I have done this:
    1. I created a new thread.
    2. I maxmized the window
    I set the following properties:
    ShowInTaskbar = False
    TopMost = True
    Focus()
    BringToFront()
    In all my testing I needed the window to be maximized, if it wasn't B1 stayed on top.

  • How to set the focus to a first element in oracle apex 3.2.1  and 3.1.2.00

    Hello ,
    I am using oracle apex 3.2.1 in development env. How to set the focus to a first element of a page.
    thanks/mahesh

    Hi,
    This might help
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/bldr_pgs.htm#CJGJDHCI
    Find "Cursor Focus" from page Display Attributes
    Br,Jari

  • How to set the focus on the new added line in ALV list (OO)

    Dear Friends,
    I have an ALV list based on OO(using alv_grid->set_table_for_first_display), when I click the 'new' button to add a new line, the mouse arrow is always pointing to the first line - not the new created line for user to input!!.
    So how to set the focus (mouse arrow) on the new added line in ALV list for user to input it friendly?
    Thanks a lot!!

    Hello,
    To get the selected line row first we have get all the rows in the internal table.
    When u click on the button when it is creating the new line we have to pass the row number to the call method
    CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->get_selected_rows
       IMPORTING
          ET_INDEX_ROWS  =   <internal table of type LVC_T_ROW > (obsolete)
          ET_ROW_NO      =   <internal table of type LVC_T_ROID > .
    CALL METHOD<ref.var. to CL_GUI_ALV_GRID>->set_selected_rows
       EXPORTING
          IT_ROW_NO  =  <internal table of type LVC_T_ROID>
       or alternatively
       IT_INDEX_ROWS  =  <internal table of type LVC_T_ROW>
          IS_KEEP_OTHER_SELECTIONS  =  <type CHAR01>.
    http://help.sap.com/saphelp_erp2004/helpdata/EN/22/a3f5ecd2fe11d2b467006094192fe3/content.htm

  • How to set the focus to the tabbed pane title?

    Dear Friends,
    I'm using tabbed pane (JTabbedPane) in my application. I have 2 tabbed panes and each contain some text fields and buttons.
    In first tabbed, I have 2 text fields, OK and Cancel buttons. I have to set the focus to the title of the tabbed pane after it lost focus from the Cancel button (focus has to move from Cancel button to tabbed pane title by pressing tab key).
    Could anyone please tell me how to set the focus to the tabbed pane title?
    Thanks in advance,
    Sathish kumar D

    Thanks for your reply.
    Could you please tell me how to set focus for title of the tabbed pane throug FocusTraversalPolicy?
    because usually we set the focus for the component by requestFocusInWindow().
    for example set focust to the button OK,
    btnOk.requestFocusInWindow()likewise could you tell me how to set focus to Title of the tabbed pane?
    Sathish kumar D

  • Setting the focus in HTREE

    Hi guys!
    I have created the tree in the form 6i. it is populated with the employee names. Then attached a horizontal toolbar canvas with the main form and the horizontal tool bar canvas contain a text item and a search button. When I find the name of the emplyee it finds it but how can i set the focus. An early response is appreciated. regards.

    Try FTREE.SET_TREE_SELECTION(tree, node, FTREE.SELECT_ON)

  • Setting the focus to a text field on a subform in the form initialize event.

    I have a form that checks the rawValue of a text field to determine whether or not the focus should be set on a particular text field. Here is the logic:
    if(txtEmailVisible.rawValue == "visible")
    frmEmailData.presence = "visible";
    xfa.host.setFocus(xfa.form.NEDA.main.frmEmailData.txtEmailBody);
    else
    frmEmailData.presence = "hidden";
    For some reason the focus isn't going to that object, instead it is still going to the first field in the tabbing order. Am I calling this in the wrong event, which is causing the tabbing order to over ride my setFocus call?
    Thanks,
    Chad

    Try using setTimeout for this from the DocReady event.
    app.setTimeout("xfa.host.setFocus(xfa.form.NEDA.main.frmEmailData.txtEmailBody);
    ", 250);
    There are several occasions where code must be executed after init/formReady/DocReady, etc. has been completed. This is one of them.

Maybe you are looking for

  • Internet Connection Instability

    Up until last week I had my home network configured in the way described below and it worked fine. Without any changes that I'm aware of, suddenly I'm having trouble staying connected to my ISP. I have a dual band network: A Time Capsule connected vi

  • How to popup system form which does'nt have MenuItemID (Form.Type = 42)

    Hi, Suppose I am adding some data to Delivary form, and when I click on the Add Button I want the Batch No selection form  with form type = 42 ,form to be opened Autmatically when the material is not assigned any batch no and issue method is backfluc

  • Full text search in CMSK 9.0.3  WebStarterApp

    I deployed WebStarterApp on CMSDK 9.0.3 and I cannot perform full text search on the CMSDK document. Is there anybody who encounters the same problem ? Thanks

  • Column name missing from a View

    I tried to create a view based on another view but the column header is missing from the view. The view was create with the following statement: create view TEST.MDQ_VU_TEST2 (FXT_BANKCODE, FXT_FCY, FXT_FXINDICATOR, SUMFXT_FXFCYAMT, SUMFXT_FXLCYAMT,

  • Accessing objects with jstl

    Hello forum, A question about JSTL - one of the things I have not figured out until now. How can you access an object declared by a specialized tag? Generaly you c:set the variable you wish and you use EL to malipulate it. But how can you access a lo