Adding 2 icons for a single node on a tree

Hi,
I am trying to create a tree to represent objects. These objects can be of different types, and different states. I intend to use two icons for each node in the tree, one signifying the type and the other the status. I am a bit stuck though.
At present each node has a single icon, and uses a JLabel to add to the tree (with a custom renderer). Is it possible to manipulate the icons so instead of adding 2 16x16icons I can simplify it by adding a 32x16 icon?
Alternativley is it possible to customise JLabel (or something) to allow two icons to be added and alligned?
Cheers in advance
Chris

Just write your own composite Icon class:
public class CompositeIcon implements Icon
  private Icon icon1;
  private Icon icon2;
  public CompositeIcon(Icon icon1, Icon icon2)
    this.icon1 = icon1;
    this.icon2 = icon2;
  public int getIconHeight()
    return Math.max(icon1.getIconHeight(), icon2.getIconHeight());
  public int getIconWidth()
    return icon1.getIconWidth() + icon2.getIconWidth();
  public void paintIcon(Component c, Graphics g, int x, int y)
    icon1.paintIcon(c, g, x, y);
    icon2.paintIcon(c, g, x + icon1.getIconWidth, y);
}Hopefully a slightly more reusable solution. You could write all sorts of different layouts in this way.
Hope this helps.

Similar Messages

  • Applying PL19 for SAP J2EE 6.20  for a Single Node

    We are trying to upgrade from EP6 SP2 patch 2 to patch 3.
    A pre-req for applying Patch3 is that we need to be at PL19. Turns out we are in between PL16 and  PL17 from a SAP J2EE 6.20 standpoint.
    We managed to download SAPJ2EE620C_19-10001433.SAR the SAR file for getting the SAP J2EE 6.20 from PL16+ to PL19.
    On reading SAP Note 529088 ( that helps you with installing the SAR file ) it seems "SAPJ2EE620C..." the 'C" in the SAR file name denotes that it is for a Cluster Node. We have a Single node install. For which we ought to see a 'S' in that place. On Service.sap.com we dont know of a place where we can find the .SAR file that we may need for a single node version.
    We  went ahead and ran the visual.bat and that brought up a screen meant for a cluster version.
    It has been two days since we have working on this.
    Anybody has any idea/experience with what we are taking about. Please help.
    thanx for your help.
    rj.

    Hi rj,
    If you have installed EP6 SP2, you have installed the Clustered Version of J2EE (dispatcher, server, state(pl21)).  The Single node was used for EP5.  I believe you are getting this terminology confused with a clustered install of EP6 for HA purposes where the actual application piece is clustered.  So even an EP6 install running on a single server runs on a the J2EE Engine Cluster. 
    So if you ran the visual.bat for PL19 and the portal started up fine, you have successfully upgraded your J2EE version to PL 19.  Just a quick hint, when you are running the patch install, select upgrade and put in the path to your instance (i.e. c:\usr\sap\DEP1\j2ee\j2ee_00).
    Hope this helps to clarify,
    Marty

  • Displaying a mixture of text and links in a single node of af:tree

    Hi,
    I want to display few links embedded in text as a node in <af:tree>.
    For example, I want a single node in a tree to show three links with text - "Different type of email services are gmail, yahoomail,hotmail".
    (gmail,yahoomail and hotmail are links)
    Is there a good way of displaying this? I tried following options
    1) I have a property named "linkText" in a bean instance mybean of MyBean.java. "linkText" contains required text and "a href" tags to display links. I used the following code in jsp page
    <af:tree>
    <f:facet name="nodeStamp">
    <f:verbatim>
    #{mybean.linkText>
    </f:verbatim>
    </f:facet>
    </af:tree>
    <f:verbatim> displays the EL expression as it is. I am not able to access the value.
    2) I also tried to use <af:outputFormatted>. Though it supports "a href" tag, it does not support "target" attribute of the same tag.
    Is there any other way of doing this?

A: Displaying a mixture of text and links in a single node of <af:tree>

On a related note ...is it possible to call a commandLink to call an existing java bean/function within an outputText?
For example:
Say I had an outputText that dumped a /etc/hosts file and I wanted to put in a command link to ping each host and pass the particular IP address to it. What would be the best method for doing that?
135.122.29.122 host1.me.com {color:#ff0000}_PingMeLink_
{color}135.122.29.117 host2.sd.me.com _{color:#ff0000}PingMeLink{color}_
So can I embed this in an outputText somehow or is there a better way to do this?
&lt;af:commandLink text="PingMeLink"
action="#{NetworkController.PingAHost}"/&gt;
Thanks for your help!

On a related note ...is it possible to call a commandLink to call an existing java bean/function within an outputText?
For example:
Say I had an outputText that dumped a /etc/hosts file and I wanted to put in a command link to ping each host and pass the particular IP address to it. What would be the best method for doing that?
135.122.29.122 host1.me.com {color:#ff0000}_PingMeLink_
{color}135.122.29.117 host2.sd.me.com _{color:#ff0000}PingMeLink{color}_
So can I embed this in an outputText somehow or is there a better way to do this?
&lt;af:commandLink text="PingMeLink"
action="#{NetworkController.PingAHost}"/&gt;
Thanks for your help!

  • Adding values for a single customer

    Hi Everybody,
    I am facing a programming issue. I have to do something like this:
    For a each customer, for all open items for that customer, I have to add the amount due at every period in aging in Accounts receivable. So for example, if I have two customers: A and B and
    A has 5 open items
    B has 3 open items
    for each open item there is an amount due for both customers. So what i have to do is add for A 1+2 = amount 1.
    amount 1 + 3 = amount 2, amount 24 = amount 3, amount 35 = amount 4.
    Similarly for B also I have to do the same thing. Right now my amount are getting added up into one single value at each line of the table. So for all customers it is just getting added in every row of the table and not seperately for every new customer.
    Can somebody suggest something or give some example?
    Please help.
    Thanks & regards,
    AM

    I'm not sure I understand what you are trying to do. Is it something like:
    REPORT ztest.
    TABLES: bsid.
    PARAMETERS p_bukrs LIKE bsid-bukrs.
    SELECT-OPTIONS s_kunnr FOR bsid-kunnr.
    DATA: BEGIN OF itab OCCURS 0,
            bukrs LIKE bsid-bukrs,
            kunnr LIKE bsid-kunnr,
            under_30_amt LIKE bsid-dmbtr,
            under_60_amt LIKE bsid-dmbtr,
            under_90_amt LIKE bsid-dmbtr,
            over_90_amt  LIKE bsid-dmbtr,
          END   OF itab.
    DATA: under_30_date LIKE sy-datum,
          under_60_date LIKE sy-datum,
          under_90_date LIKE sy-datum,
          over_90_date  LIKE sy-datum.
    under_30_date = sy-datum - 30.
    under_60_date = sy-datum - 60.
    under_90_date = sy-datum - 90.
    over_90_date  = sy-datum - 30.
    SELECT bukrs kunnr bldat dmbtr
      INTO CORRESPONDING FIELDS OF bsid
      FROM bsid
      WHERE bukrs = p_bukrs
        AND kunnr IN s_kunnr.
      CLEAR itab.
      MOVE: bsid-bukrs TO itab-bukrs,
            bsid-kunnr TO itab-kunnr.
      IF bsid-bldat > under_30_date.
        MOVE bsid-dmbtr TO itab-under_30_amt.
      ELSEIF bsid-bldat > under_60_date.
        MOVE bsid-dmbtr TO itab-under_60_amt.
      ELSEIF bsid-bldat > under_90_date.
        MOVE bsid-dmbtr TO itab-under_90_amt.
      ELSE.
        MOVE bsid-dmbtr TO itab-over_90_amt.
      ENDIF.
      COLLECT itab.
    ENDSELECT.
    LOOP AT itab.
      WRITE: /001 itab-bukrs,
                  itab-kunnr,
                  itab-under_30_amt,
                  itab-under_60_amt,
                  itab-under_90_amt,
                  itab-over_90_amt.
    ENDLOOP.
    <i>Caveats</i>
    I'm not sure what date you should use for aging. I used the document date. Maybe it's the baseline date. Maybe it's something else.
    Collect is inefficient. You might want to do it another way.
    I may be way off base - you may be doing something else entirely.
    Rob

  • I want to change different icon for different leaf node

    Hi,
    i am reading file system(win 2000)and showing in a tree.i want to
    show different icon for different file extension.
    Pl suggest me with sample code,how should i do?
    Thanx

    Hi...
    To do this, u need to write ur own TreeCellRenderer.
    ex :
    class FileSystemTreeCellRenderer extends JLabel implements TreeCellRenderer
         File file= null;
         public FileSystemTreeCellRenderer(File f)
              this.file = f;
         public Component getTreeCellRendererComponent
                   JTree tree,
                   Object value,
                   boolean selected,
                   boolean expanded,
                   boolean leaf,
                   int row,
                   boolean hasFocus
              if(file.isDirectory())
                   setIcon("your image");
                   setText("file/dir name");
              else
                   setIcon("your other image");
                   setText("file/dir name");
         return this;
    Hope it suits ur need .. (also, using the file extensions, u can set different icons following the above strategy...)
    Regards,
    Ramanujam

  • Ho to set different Icon for different Jtree Nodes dynamically??

    Dar Friends:
    I have following code.
    But if poosible I hope to:
    [1]. Dynamically assign or st each node with different Icons;
    [2]. these icons have different sizes, hope to resize them with same size, ie. 20X 20
    But try whole day, no idea how to to it,
    Can somebody throw a light??
    Thanks
    Good weekends
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    /** JTree with missing or custom icons at the tree nodes.
    *  1999 Marty Hall, http://www.apl.jhu.edu/~hall/java/
    public class CustomIcons extends JFrame {
      public static void main(String[] args) {
        new CustomIcons();
      private Icon customOpenIcon = new ImageIcon("images/Circle_1.gif");
      private Icon customClosedIcon = new ImageIcon("images/Circle_2.gif");
      private Icon customLeafIcon = new ImageIcon("images/Circle_3.gif");
      public CustomIcons() {
        super("JTree Selections");
        Container content = getContentPane();
        content.setLayout(new FlowLayout());
        DefaultMutableTreeNode root =
          new DefaultMutableTreeNode("Root");
        DefaultMutableTreeNode child;
        DefaultMutableTreeNode grandChild;
        for(int childIndex=1; childIndex<4; childIndex++) {
          child = new DefaultMutableTreeNode("Child " + childIndex);
          root.add(child);
          for(int grandChildIndex=1; grandChildIndex<4; grandChildIndex++) {
            grandChild =
              new DefaultMutableTreeNode("Grandchild " + childIndex +
                                         "." + grandChildIndex);
            child.add(grandChild);
        JTree tree3 = new JTree(root);
        tree3.expandRow(3); // Expand children to illustrate leaf icons
        DefaultTreeCellRenderer renderer3 = new DefaultTreeCellRenderer();
        renderer3.setOpenIcon(customOpenIcon);
        renderer3.setClosedIcon(customClosedIcon);
        renderer3.setLeafIcon(customLeafIcon);
        tree3.setCellRenderer(renderer3);
        JScrollPane pane3 = new JScrollPane(tree3);
        pane3.setBorder(BorderFactory.createTitledBorder("Custom Icons"));
        content.add(pane3);
        pack();
        setVisible(true);
    }

    Thanks for your advice,I post my code as below, (I cannot post Max 5000, so post twice)
    [1]. main:
    import javax.swing.*;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.*;
    import java.awt.*;
         public class JTreeNew  extends JFrame {
           public JTreeNew() {
             super("Editable Tree Frame");
                JTreeSub js = new JTreeSub();
             setSize(200, 200);
            // WindowUtilities.setNativeLookAndFeel();
            // addWindowListener(new ExitListener());
             setDefaultCloseOperation(EXIT_ON_CLOSE);
           public class JTreeSub  extends JTree implements TreeSelectionListener{
                DefaultTreeModel treeModel;
                JTree tree;
                ContainerIconNode selectedNode;
                public JTreeSub() {
                super();
                init();
                public void init(){
                  ContainerIconNode Root = new ContainerIconNode("images/Root.GIF");
                  ContainerIconNode Animal = new ContainerIconNode("images/Animal.GIF");
                  ContainerIconNode Cat = new ContainerIconNode("images/Cat.GIF");
                  ContainerIconNode Fish = new ContainerIconNode("images/Fish.GIF");
                  ContainerIconNode GoldFish = new ContainerIconNode("images/GoldFish.GIF");
                  ContainerIconNode CatFish = new ContainerIconNode("images/CatFish.jpg");
                  ContainerIconNode Solomon = new ContainerIconNode("images/Solomon.GIF");
                  ContainerIconNode DogFish = new ContainerIconNode("images/DogFish.GIF");
                  ContainerIconNode Dog = new ContainerIconNode("images/Dog.jpg");
                  ContainerIconNode Mouse = new ContainerIconNode("images/Mouse.GIF");
                  ContainerIconNode Chicken = new ContainerIconNode("images/Chicken.GIF");
                  ContainerIconNode Pig = new ContainerIconNode("images/Pig.GIF");
                  treeModel = new DefaultTreeModel(Animal);
                  tree = new JTree(treeModel);
                  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
                  ToolTipManager.sharedInstance().registerComponent(tree);
                  //Listen for when the selection changes.
                 tree.addTreeSelectionListener(this);
                  tree.setEditable(true);
                  treeModel.insertNodeInto(Animal,Root, 0);
                  Animal.add(Cat);
                  Animal.add(Fish);
                  Fish.add(GoldFish);
                  Fish.add(CatFish);
                  Fish.add(Solomon);
                  Fish.add(DogFish);
                  Animal.add(Dog);
                  Animal.add(Mouse);
                  Animal.add(Chicken);
                  Animal.add(Pig);
                  tree.expandRow(3); // Expand children to illustrate leaf icons
         //         DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
         //         renderer.setOpenIcon(Animal.getImageIcon());
         //         renderer.setClosedIcon(Dog.getImageIcon());
         //         renderer.setLeafIcon(CatFish.getImageIcon());
         //         tree.setCellRenderer(renderer);
                  ImageIcon startIcon = new ImageIcon("images/89.gif");
                  tree.setCellRenderer(new MyRenderer(startIcon));
                  getContentPane().add(tree, BorderLayout.CENTER);
              @Override
              public void valueChanged(TreeSelectionEvent e) {
                   selectedNode = (ContainerIconNode)
                                    tree.getLastSelectedPathComponent();
                 if (selectedNode == null) return;
                 Object nodeInfo = selectedNode.getUserObject();
                 if (selectedNode.isLeaf()) {
                      System.out.println("<JTreeNew> Node is  leaf=");
                 } else {
                      System.out.println("<JTreeNew> Node is  folder");
           private class MyRenderer extends DefaultTreeCellRenderer {
                 Icon nodeIcon;
                 public MyRenderer(ImageIcon icon) {
                      nodeIcon=icon;
                 public Component getTreeCellRendererComponent(
                                     JTree tree,
                                     Object value,
                                     boolean sel,
                                     boolean expanded,
                                     boolean leaf,
                                     int row,
                                     boolean hasFocus) {
    //                  System.out.println("<JTreeNew> Tree="+ tree);
    //                  System.out.println("<JTreeNew> nodeIcon="+ nodeIcon);
                      System.out.println("\n<JTreeNew> value="+ value);
                      System.out.println("<JTreeNew> sel="+ sel+"\n");
    //                  System.out.println("<JTreeNew> expanded="+ expanded);
    //                  System.out.println("<JTreeNew> leaf="+ leaf);
    //                  System.out.println("<JTreeNew> row="+ row);
    //                  System.out.println("<JTreeNew> hasFocus="+ hasFocus);
                     return this;
           public static void main(String args[]) {
                JTreeNew st = new JTreeNew();
                st.setVisible(true);
         }

  • Coherence 3.5 - slow start for a single node

    EDIT - wrong forum
    Edited by: user10613309 on 30-Jul-2009 02:42

    Hi Tim,
    The only parameter that controls the delay for the very first cluster member is the "join-timeout-milliseconds" element (http://wiki.tangosol.com/display/COH35UG/multicast-listener). I don't think any of the default values change in 3.5, but the value differs dramatically between the evaluation and development modes (3 sec) and the production mode (30 sec)
    Regards,
    Gene

  • Change the default icon for unsatisfied node

    Is it possible to change the default icon for the unsatisfied node (unsatisfied indicator). I have checked the UI content element with the same name, but it does not have the source file setting in it, so I guess it is hard coded. I tried to change the source file with the name unsatisfied_status.gif to a different image and it works, but this will be a system wide change. I want to do this as a model specific change. Has anyone done this before? Thanks in advance.
    Cheers,
    Biju.
    [My Oracle Blog|http://oraclewithbiju.blogspot.com]

    Did you try changing image name in UI edit page?
    UI edit page lists few images which can be changed for each UI, like unsatisfied indicator, logic status icons etc.

  • Custom icon for tree node

    Hi,
    Can anyone tell me how to change the icon for a particular node in a JTree?
    I know how to change all the leafs for example by using the DefaultTreeCellRenderer.setLeafIcon()method. But do you know how to set just one node to a particular icon?
    Cheers,
    Jim

    MyTreeCellRenderer extends DefaulTreeCellRenderer{
      public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean sel,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
        super.getTreeCellRendererComponent(
          tree, value, sel,
          expanded, leaf, row,
          hasFocus);
        //Do your condition on your value
        if( value ....){
         setIcon(myIcon);
        return this;
    }

  • Install a grid infrastructure for a cluster for single node Windows Server

    Hello,
    Can you suggest me how to install a Oracle Single Node RAC 11g on a Windows Server 2008 x64 bits? It's for testing purposes and I don't need two nodes. I know that Linux is better, but my company only uses Windows servers. Our former consultant was able to do it, but didn't tell us how to and that server was lost.
    I know that we have to install first Grid Infrastructure. Running the "Oracle Grid Infrastructure" installer, I could successfully install a "Grid Infrastructure for a Standalone Server". But that grid is not for a RAC database. When trying to install the Database software, it allowed to me to only install "Single instance database", not "Real Application Cluster database installation".
    Running the "Oracle Grid Infrastructure" installer, I tried to select option:
    "Install and Configure Grid Infrastructure for a Cluster" -> Typical Installation:
    SCAN Name: SRVORAC-cluster
    Validating SCAN information
    INS-40922 Invalid SCAN Name - unresolvable to IP address.
    Is it possible to install a grid infrastructure for a cluster for a single-node or one-node Windows Server ?
    Edited by: user521219 on Jan 30, 2012 12:46 PM

    HI,
    You probably have misconception about Single node RAC. This feature does not need that you have only one physical machine in a RAC, it actually means that in a RAC environment (2 or more nodes), you can run your database on only one node(single instance) and then later you can move this single instance to any other node of the RAC (so that you can do some patching on this node making your database available all the time). This also has some other benefits, see bellow.
    http://www.oracle.com/technetwork/database/clustering/overview/ug-raconenode-2009-130760.pdf
    http://docs.oracle.com/cd/E11882_01/install.112/e25666/whatsnew.htm#sthref8
    Salman

  • How to set the icon for the entire application with JFrame.setIconImage

    I set the icon on the main frame using JFrame.setIconImage(). The icon is shown properly in the main frame.
    If more JFrames are opened from the main frame, the newly opened JFrames also show the icon.
    However if JDialogs are opended, in some cases the icon set on the main frame is shown and in other cases the coffee cup.
    What is JFrame.setIconImage() expected to do? Setting the icon for a single JFrame or the entire application?
    How can I set the icon for the entire application?
    How can I set the icon for JDialogs?
    Thank you

    In order for your dialogs to use the same icon as the frame, you must parent the dialogs to the frame which has the custom icon.
    See the following thread for more information: http://forum.java.sun.com/thread.jsp?forum=57&thread=362542
    cheers,
    Greg

  • How do I remove expand / collapse icon for JTree empty folders

    Hi
    I am using a JTree as a file system browser. I use DefaultMutableTreeNode nodes.
    I have a problem with empty folders.
    Empty folders show the expand / collapse icon, leading the user to believe there are sub-directories. When the user double-clicks the folder, the expand / collapse icon goes away. This is a "haha-gotcha" glitch that I really don't want my users to have to continually deal with.
    So, how might I get my JTree to not show the expand / collapse icon for empty folders?
    Thanks
    Wayne

    Maybe I can use the FileSystemView isTraversable(File f) method in my TreeCellRenderer class to check if anything is in the directory.
    But I still need to know how to disable the expand / collapse icon for such a node.

  • Globally setting icon for a file type

    I've been using LilyPond a lot recently. The .ly files it saves don't have their own icon, though, they just get the generic document icon. I know that I can manually set an icon for a single file using 'Get Info', but it's not practical now because I have so many .ly files. Is there a way I can tell OS X to use my own icon every time it sees a .ly file?
    Thanks,
    (- Steve -)

    Hi, Stephen.
    If by LilyPond you mean this application, it's the application's responsibility to assign the custom icon for files it creates, e.g. .ly files you edit and save in LilyPond. You might want to send feedback concerning this to the developers. However, as I understand the application based on a quick review of its manual, it can work with any plain-text (ASCII) file.
    You can change the default application in which all .ly files open by using the instructions in "Mac OS X 10.4 Help: Changing the application that opens a document." That may result in those files bearing the same icon as the LilyPond application. That is also the mechanism by which a given icon is assigned to all files of a given type.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • Install RAC OBS on single node using VMWare

    Re: How to install Muti_node R12 using VMWARE
    Mine is a little different.
    I have the Test server which has OEL5 and one OAS 10g(Oracle application Server) with 10g database.
    I want to install RAC OBS on this server by installing VMWare for the single node. I do not want to wipe out the OAS, reinstore OSL5 and start from a blank machine.
    Can I keep what I have on the server and install RAC OBS by installing VMWare, configuring the virtual sharing disks, and install RAC OBS using ASM?

    Hi,
    Can I keep what I have on the server and install RAC OBS by installing VMWare, configuring the virtual sharing disks, and install RAC OBS using ASM?Yes, you can. Just make sure you have sufficient resources on this machine.
    Note: 388577.1 - Using Oracle 10g Release 2 Real Application Clusters and Automatic Storage Management with Oracle E-Business Suite Release 12
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=388577.1
    Regards,
    Hussein

  • Regarding Leaf node indentation in tree

    Hi All,
    I need solution for indenting leaf nodes alone  in  Tree.
    regards,
    karthik

    Hi,
    Found the solution.
    Juts keep on reading all the nodes, system gives the complete path of the tree by using Lead selection and then we can use this path to peform the update operation on tree structure.
    Thanks alot for the hint.
    Regards
    PG

  • Maybe you are looking for

    • How do i restore my macbook pro to its out of the box settings?

      Hi folks, I recently got a new macbook pro and used Time Machine to import all of my data and settings from my old macbook into my new one. I am now realizing that there is a bunch of stuff on my old hard drive that I don't want on my new one. What I

    • Better Photoshop integration for exported jpegs

      Hi Jpegs exported by LR have to be saved with new compression parameters if opened & then worked on in Photoshop. This can be very annoying & time consuming when working with numerous files which need a minor correction (such as dodging & burning whi

    • Deploy an Applet across multiple servers

      I have an applet which will need to be deployed over numerous servers and urls. I was wondering if there was a way for the applet to know which ip/url it was run from, without making a properties file and packaging it in the applets jar file. As an e

    • Can't import content with '&' in XML element

      I encountered the following error msg when importing the sample XML with '&' in content of an element(for example, a URL with '&' for parameters): <?xml version = '1.0'?> <ROW_List> <ROW> ...... <D3_STRU_URL>http://www.ncbi.nlm.nih.gov/mmdbsrv.cgi?fo

    • Table or function module to update ibase

      Hi experts, I am using the transaction crmd_order to create a sales order and i am assigning the warranty product to it , now my requirement is, i have to update that warranty product in the ibase( ib52 ). so for that what is the table or function mo