Expanding JTree nodes to the left.

I have a JTree with a custom model and cell renderer but now i'd like to flip the entire tree so that the root node ends up in the upper right corner and the child nodes expand to the left (instead of to the right).
I tought this should be easy enough but now I'm very confused; any help is appriciated!

Hi,
as a general guideline - you want to set something - so search for all set....-methods that class has or inherits.
public void setComponentOrientation(ComponentOrientation o)
Set the language-sensitive orientation that is to be used to order the elements or text within this component. Language-sensitive LayoutManager and Component subclasses will use this property to determine how to lay out and draw components.
At construction time, a component's orientation is set to ComponentOrientation.UNKNOWN, indicating that it has not been specified explicitly. The UNKNOWN orientation behaves the same as
ComponentOrientation.LEFT_TO_RIGHT.
To set the orientation of a single component, use this method.
Hope, this helps
greetings Marsian

Similar Messages

  • Bug - View changes to grid when expanding a collection in the left pane.

    Tried submitting this via the bug report form but got java errors. Sigh...
    This seemed like the best alternative.
    ******BUG******
    Concise problem statement:
    View changes to grid when expanding a collection in the left pane.
    Steps to reproduce bug:
    1. Goto Library Module
    2. Ensure there is a collection with at least one child - if not create one.
    3. Make sure the collection is collapsed (you cant see the child and you see a right pointing triangle to the left of the collection name)
    4. Change to Loupe view
    5. Click the right pointing triangle next to the parent collection you just created to expand it.
    Actual Results:
    View changes to grid
    Expected results:
    View should remain unchanged - in this case Loupe view.

    The first is that I can't view the aperture library anymore directly from iphoto.
    THat is exceeding strange since iPhoto '08 could not open or share an Aperture library - that ability was first introduced in iPhoto '11 - with the latest version of iPhoto and or Aperture you can open the same library with either application - http://support.apple.com/kb/HT5043
    In the current version of iPhoto the photos are sorted by date in the film strip - I've not recently done a calendar so do not remember the specifics -
    LN

  • JTree - How to Expand all Nodes in the Tree

    I have a tree that has one primary node, two sub-nodes, and multiple sub-sub-nodes under those. I want to expand (show) all these nodes in the tree when the tree first loads. I tried expandRow() but that only seems to expand one row at a time by entering a single integer for the row. Is there any way to expand all rows/nodes when loading the tree?

    see
    http://forum.java.sun.com/thread.jsp?forum=57&thread=148793

  • JTree Nodes with the same name

    What do I have to do to get the JTree to render nodes with the same name? These Nodes user objects are completely different object types and each has a unique hashcode.
    + Root Node
    +-- node1 (this is a folder)
    +-- node1 (this is a file)
    The problem is I have n folders in my tree but if a parent folder contains a folder and a file with the same name then no other subfolders are displayed.
    The nodes exist in memory because I enumerate the tree and display its contents in System.out.
    Thanks in advance!
    Matt

    Thank you to everyone that responded. I solved the issue. It was a timing issue...here's my original method:
    private void renderProductFolder(SubFolder sf){
    try{
    WTPart part = QueryHelper.service.findWTPart("number", sf.getNam());
    WTTreeNode node = buildWTTreeNode(part);
    super.getTreeModel().setRoot(node);
    renderTree(node, sf); // This is the problem call
    super.getSelectionModel().
    setSelectionPath(new TreePath(node.getPath()));
    super.expandPath(new TreePath(node.getPath()));
    }catch(Exception ex){
    ex.printStackTrace();
    Here is the fix:
    private void renderProductFolder(SubFolder sf){
    try{
    WTPart part = QueryHelper.service.findWTPart("number", sf.getNam());
    WTTreeNode node = buildWTTreeNode(part);
    renderTree(node, sf); // This was the problem call
    super.getTreeModel().setRoot(node);
    super.getSelectionModel().
    setSelectionPath(new TreePath(node.getPath()));
    super.expandPath(new TreePath(node.getPath()));
    }catch(Exception ex){
    ex.printStackTrace();
    I was originally building the root node, then setting it as the root, then adding additional nodes to the root in the call to renderTree(). So the fix was to build the complete tree structure and then call setRoot(). Otherwise the tree doesn't automatically paint the nodes when they're added via node.add(nodeChild).
    It was just a coincidence that I discovered this problem with nodes having the same name.
    Thanks for all your great input!
    Matt

  • Set different color for one JTree node

    hello,
    I managed to find how to set a color for Jtree nodes but the problem is that with my method all the nodes will b the same color whereas i'm looking to have nodes of different color depending on the situation.
    the method for setting all Jtree nodes the same color(other than black):
    tree.setCellRenderer(
    new DefaultTreeCellRenderer() {
       public Color getTextNonSelectionColor() {
         return Color.lightGray; } });I WANT TO CHOSSE EACH COLOR FOR EACH NODE
    help plz
    thanks

    You need to implement TreeCellRenderer interface
    public Component getTreeCellRendererComponent(JTree tree,
                                                  Object value,
                                                  boolean sel,
                                                  boolean expanded,
                                                  boolean leaf,
                                                  int row,
                                                  boolean hasFocus)You can know which node is rendering by check value argument. Please read DefaultTreeCellRenderer's code.

  • Help: How to make the top level navigation into vertical at the left panel

    We have a need to change the top-level and 2nd-level navigation bars (horizontal)
    into the nodes on the left navigation panel (vertical).
    We find some way but it is a very extensive job.
    Is there any way to do it quickly?
    Thanks a lot! Points guaranteed.

    Hi,
    Try to develop your own menu by using Navigation Tag Libraries. Check this link :
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/42/f35146a7203255e10000000a1553f7/frameset.htm">Navigation Tag Library</a>
    There is also sample codes. You can start your project from this codes.
    Regards
    Abdul.

  • Selecting all hierarchy nodes in the report

    Hi Friends,
    In my report I have a Hierarchy 0ORGUNIT,  there are a few sub nodes under this hierarchy.
    When the user runs the report if they want to see all the  nodes under a top node, they have to  expand each node till the last node and select them one by one.
    My question is,  is it possible to select all the sub nodes under a node just by selecting the top node?.
    If yes can someone please let me know how to do this?.
    I did check the sdn, but could get anything.
    Thanks in adv.
    Regards
    BN

    Hi,
    You can do that for the initial display i.e. the very first time you execute the query but once you collapse all the nodes you will not be able to expand all the nodes with one click.
    For showing different levels in the first display go to the characteristic properties on which you have hierarchy maintained, in the hierarchy properties section set the option 'Expand to Level' and hierarchy will be expaned for all the nodes till the level you select.
    Regards,
    Durgesh.

  • APEX Tree.  Keep focus on expanded leaf node.

    How do I prevent my tree from jumping back to the top when I expand a leav node that is below the screen scroll. I have a single parent of CORP with about 30 leaf nodes as its direct children. I have to scroll down to expand a node towards the bottom of the list. When I scroll down and expand, the page refreshes and jumps back to the top so now I have to scroll down again to expand the next node, etc. My current Tree Qurey is like
    select CHILD_ID id,
    PARENT_ID pid,
    CASE WHEN CHILD_ID = :P23_TARGET THEN
    CASE WHEN :P23_STATUS = 'Target Up' THEN
    '<span styl="color:green;">' || ITEM_NAME || '</span>'
    ELSE ITEM_NAME
    END
    ELSE
    ITEM_NAME
    END name,
    'f?p=&APP_ID.:23:'||:SESSION||'::NO::P23_TARGET:'||CHILD_ID link,
    null a1,
    null a2
    from CORP_SVR_HRCHY_VW

    Hi,
    You have to use the Anchor ID functionality of a browser - this allows you to add #id to the end of the url where id refers to the id attribute of the item that should receive the focus when the page is reloaded.
    As an example: [http://apex.oracle.com/pls/otn/f?p=33642:200]
    This, of course, requires a bit of setting up, but is easily doable.
    For this example, my SQL statement for the tree is:
    SELECT 1 ID, NULL PID, 'Top' NAME, NULL LINK, NULL A1, NULL A2 FROM DUAL
    UNION ALL
    select "EMPNO" id,
           1 pid,
           "ENAME" name,
           'f?p=' || :APP_ID || ':200:' || :APP_SESSION || '::::P200_EMPNO:' || EMPNO || '#node' || EMPNO link,
           'node' || EMPNO a1,
           null a2
    from "#OWNER#"."EMP"You will note that the URL contains *'#node' || EMPNO* at the end of the link - for an EMPNO of 1234, this would add *#node1234* to the end of the URL. You will also note that I've added *'node' || EMPNO* to the A1 column - whatever I add into this column becomes available for use in the output by referencing it as #A1# in the template. On the tree's template definition, wherever there is an A tag, I've included:
    ID="#A1#"as an attribute of the tag. For example, on the "Name Link Anchor Tag" setting, I have:
    &lt;a href="#LINK#" ID="#A1#"&gt;#NAME#&lt;/a&gt;and, wherever #A1# appeared outside of an A tag, I have removed it (otherwise, the "node1234" text would appear at that point in the page).
    Andy

  • JTree: Problems updating the nodes size

    Hi,
    I'm trying to update the content of a JTree and I wonder how it
    really works, since the paint() method doesn't seem to call the
    renderer.
    My situation: Imagine a JPanel splited in two by a JSplitPane. In
    the left is the tree. Each node in the tree shows two panels, one
    aligned to the left, and another to the right. I need that the panel
    containing the two use all the available space in the left part of the
    Split panel.
    My solution: I pass the left JPanel to the tree renderer, so that
    it can get the width from it (inside the
    getTreeCellRendererComponent()) to build the return JPanel with the
    correct size. My logic is that since each time you move the JSplitPane
    the JTree paint() method is invoked the renderer can return the
    correct JPanel with the correct size that will be painted then in the
    screen.
    My problem: Doens't work. When I render the tree, the renderer is
    invoked, but it doesn't change its size (I can change the color based on the width, but not the node size). Only when I collapse & expand a node, it correctly takes into account the .setPreferredSize() and returns the JPanel with the correct size.
    The only way I found to update the tree involves to catch the
    JSplitPane event and call updateUI() in the tree, something that, I
    think, it's certainly not the correct way to do it.
    Any explanation of why this doesn't work would be really great. Any
    pointer to a web resource explaining in deep how Swing components work (specially the JTree) would be a godsend.
    Thanks,
    - Juancho

    My situation: Imagine a JPanel splited in two by a JSplitPane. Got it.
    In the left is the tree. In the left side of the JSplitPane is a JTree.
    Each node in the tree shows two panels,Maybe... on the right side of the JSplitPane are two Panels in which the data depends on which node is selected in the JTree???
    Maybe... you have a custom TreeCellRenderer which displays a pair of panels in place of the standard JLabel???
    one aligned to the left, and another to the right. To the left of what??? To the right of what???
    I need that the panel containing the two use all the available
    space in the left part of the Split panel.Panel containing the two what??? I thought the left part of the SplitPanel contained a JTree???

  • How do i get to display the nodes under the root node in a JTree?

    In my JTree there is a root node.This root node has 4 child nodes.Each child node in turn has nodes under it.What i need to do is just display the child nodes under the root node i.e., the four child nodes and keep these child nodes in a collapsed state.How do i go sbout this?

    Please try this:
    tree.expandRow(0);
    SwingUtilities.invokeLater(new Runnable(){
        public void run(){
            tree.setRootVisible(false);
    });If you want to show the RootHandles:
    tree.setShowsRootHandles(true);If you want to keep nodes in collapsed state (not expandable):
            tel = new TreeWillExpandListener() {
                public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
                    throw new ExpandVetoException( event, "Don't want" );
                public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
            tree.addTreeWillExpandListener(tel);Some reading material:
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
    http://java.sun.com/docs/books/tutorial/uiswing/events/treewillexpandlistener.html
    Edited by: Andre_Uhres on Nov 14, 2007 5:17 PM
    Edited by: Andre_Uhres on Nov 14, 2007 5:33 PM
    Edited by: Andre_Uhres on Nov 14, 2007 5:39 PM

  • How to post an Event (mouse left click) to JTree node

    Hi,
    I am using JTree for my application just like the windows explorer tree. By default, Jtree node will got focus using left click. But, I'd like that my tree will detect a right click so that I can copy any file to the Jtree. I've added a mouselistener to it but the node is not selected by the right click. Anyboby can teach me how to post a mouse left click event to the Jtree so that it will become selected using left click.
    Thanks a million

    See if this is useful
    public void mouseClicked(MouseEvent event)
    Object object = event.getSource();
    if (object == mTree)
    mTree_mouseClicked(event);
    private void mTree_mouseClicked(MouseEvent event)
    if(event.getModifiers()==event.BUTTON3_MASK)
    //your logic goes here
    }//close method

  • How do I expand the left panel to see more of my folder names?

    Or (alternatively), how do I hide (but not delete) upper-level folders so that my folder names don't get cut off? Here's a screen shot:

    gatorjim2000 wrote:
    In a word or two, you can't. You can drag the border between the left panel and the viewing area to enlarge the panel, but it only goes so far.
    That's not quite true.
    You can use Jeffrey's tool to expand the maximum width of the panels, and use narrower fonts if you want:
    http://regex.info/Lightroom/Config/

  • How to get the path of the selected Jtree node for deletion purpose

    I had one Jtree which show the file structure of the system now i want to get the functionality like when i right click on the node , it should be delete and the file also deleted from my system, for that how can i get the path of that component
    i had used
    TreePath path = tree.getPathForLocation(loc.x, loc.y);
    but it gives the array of objects as (from sop)=> [My Computer, C:\, C:\ANT_HOME, C:\ANT_HOME\lib, C:\ANT_HOME\lib\ant-1.7.0.pom.md5]
    i want its last path element how can i get it ?

    Call getLastSelectedPathComponent() on the tree.

  • How to use custom nodes in a JTree without reinventing the wheel?

    Hello,
    Each node contains two JTextAreas in a Box layout and a few JButtons.
    I wish to display these nodes in a JTree.
    Reading the tutorial, it seems I would have to reimplement the TreeModel, TreeCellRenderer/Editor, MutableTreeNode interfaces etc.
    Can I use the DefaultTreeModel, and other standard widgets (great stuff!) to minimize the amount of reimplementation I must do. aka avoid reinventing the wheel? I was thinking of extending my node from the DefaultMutableTreeNode class - however it does not display the nodes with the TextAreas, buttons etc.
    any help appreciated.
    thanks,
    Anil

    was able to fix it over here:
    http://forum.java.sun.com/thread.jspa?messageID=4089777

  • How to set a particular node selected in a JTree from within the model

    I have an adapter class that provides communication between my JTree and data model. My adapter class implements TreeModel, TreeExpansionListener, TreeSelectionListener and a listener for changes to my data model.
    My data model keeps reference to the currently selected node. It is working quite nicely when I select a tree node with the mouse (the data model is updated accordingly with the node selected), however my problem occurs trying to go the other way (set the selected node in my data model and have it reflected in the tree).
    I know that my selection in the tree is changing correctly as when the selection changes it fires off an event to update the attributes window associated with the currently selected node. I just can't get the node to become highlighted.
    Any ideas would be most welcome.
    Thanks,
    Beck.

    Does your model really have to keep track of the selected item or can the two views (the JTree and the attributes window) not be coupled together in the user interface instead?
    Failing that, you could always consider implementing TreeSelectionModel as well and calling JTree.setSelectionModel since you're keeping track of the tree selection for it already. This is quite a bit of work though.
    If that's too much trouble then if you can work out the TreePath for the node that's been programmatically selected through your model then you could use JTree.getSelectionModel().setSelectionPath. Have a look at tree.getSelectionModel().setSelectedPath(new TreePath(selectedObject)).
    This approach is a bit warped, though, since it implies that your model knows about the view and therefore couples them together.

Maybe you are looking for

  • CR 2008 - Optional parameter prompts

    Hi! I sometimes use Optional parameter prompts in Crystal Reports 2008. The main reason is to minimise user input in Selection Criteria Screen. I have many subreports, and not all prompts are needed for all subreports. If the user leaves the prompt b

  • HT4910 back up in iCloud

    how can i back up my hard drive to iCloud, I want to use icloud fortime machine, is there a way?

  • Activation issue Macromedia Studio MX 2004

    Can anyone tell me how to activate Studio MX 2004? I've had this software for years and now I have a new computer and I need to continue to use it. I realise that it is old software but it meets my needs and I have no interest in more bells and whist

  • Box desinging

    Dear All, i want to draw  box to each widow in smartforms,i tried with tables it is not comming correctly it is comming for single line plz guid md. Thanks. Abaper

  • Record button not working on Online Sky Guide

    Not working for this page for example: http://tv.sky.com/tv-guide#/programme/detail/1813/922