How to set different Icons for Jtreenode

How to set different Icons for Jtreenode,i want to set icons for jtreenode,not only for leaf,open,closeicon,i hope that each node has a different icon.Thanks!

you need to check for the node value within a renderer, then assign an icon based on what you expect to get back.
check out this page. http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html

Similar Messages

  • How to set different icons for different windows which is seen in the top left corner?

    Hi
    How to set different icons for different windows which is seen in the top left corner? I know when building exe there is a option to edit icons or add icons and that icon is default for all the windows in the project. But i want different icons for different windows which is possible in VB.
    Is there any way to set icon by calling any dlls.
    Thanks & Regards
    Samuel J
    [email protected]

    Hi Sam,
    no problem. See the attachment.
    Mike
    Attachments:
    TestIcon_LV85.zip ‏44 KB

  • How to set different icon for different type of document

    Hi,
    In my repository, we have different kinds of document (crystal report, word document, excel, jpg ...) and we wanna show specific icon for each kind. In my used ResourceRender I cann't see where to change (rnd:icon?)
    Could someone tell me how to achieve that? Thanks
    Ray

    Hi Ray Li,
    in KM icons are mapped to mime types. You can add a mapping or change an existing one as follows:
    1. Go to Systemadministrarion - System Configuration - Knowledge Management - Content Management - Utilities - Icons
    2. Add your mime mapping or change an existing one. To determine the correct mime type of your documents, just have a look at the details dialog in KM.
    3. The path to the icons points (by default) to following directory on your KM server: usr\sap\SID\SYS\global\config\cm\etc\public\mimes\images
    Here you can replace images or add some new.
    Hope this helps,
    Carsten
    Seems like somebody thought the same thought bit faster than I did. Would like to delete my answer that does not contain any additional info. But dunno how to.
    Message was edited by: Carsten Buechert

  • How to create a Platinum,Gold and Silver Customer and how to set different price for a single material based on customer?

    Hi All,
    How to create a Platinum,Gold and Silver Customer and how to set different price for a single material based on customer?
    Assume Material is Pen.
    While creating Sales Order in VA01 how to bring different price for the same material for Platinum,Gold and Silver Customers.
    Kindly help me out.
    Thanks,
    Renjith Jose

    A good place to start is http://www.javaworld.com/javaworld/javatips/jw-javatip34.html
    Also, do a search in this forum on HttpURLConnection. That class allows you to use POST method to send form data to a web server.
    "Hidden" variables are only hidden in HTML. The HTTP that gets POSTed to the web server doesn't distinguish between hidden and not hidden. That is, the content you would write to the HttpURLConnection.getOutputStream() would be something like:
    hidden=1&submit=ok(Of course, the variable names would depend on what the web server was expecting from the form.)
    Also, be sure to set the Content-Type request parameter to "application/x-www-form-urlencoded"

  • How to display different icon, for different node of jtree

    Hi All,
    How to display different icon, for different node of jtree

    you haven't responded to my last post here: [http://forums.sun.com/thread.jspa?threadID=5323190&messageID=10382676#10382676|http://forums.sun.com/thread.jspa?threadID=5323190&messageID=10382676#10382676]

  • How to set different header for different Standard report page

    How to set different header for different Standard report page

    Hi,
    A easy answer would be use the 'set report header text.vi' but maybe you are talking about something else ?

  • 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 to set different font for a particular row in jtables?

    How to set different font size and font type for a particular row in jtable?

    More than enough sample code here:
    [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]
    db

  • How to set different sounds for different events?

    Hello I had Xiaomi Mi2s before and I could set different sound for every email account I had, for sms, for facebook and so on. How do I do it on my Xperia? Of course that for example SMS is more important then some facebook comment, so I would like to hear what happened because not every time I want to reach my phone.

    Open each app > menu > settings > notification sound > change the sound > done > repeat as needed 
    "I'd rather be hated for who I am, than loved for who I am not." Kurt Cobain (1967-1994)

  • How to set different ringtones for contacts ?

    hi!, i got my iphone friday night and ive tried setting different ringtones for different people..but it doesnt work...my normal ringtone is disturbed..when my friends call..i want it to be different for each one of them..i changed it in the contacts...everytime they used to call it would say there name..ever since i put the ringtone in..the phone doesnt recognize the contact?

    Try a reset and/or restore.
    It should work, mine work properly.

  • How to set an icon for a JLabel with Advanced Synth

    Hello,
    Do you know how to define an icon for a JLabel components with Advanced Synth (with a XML file) ? I have tried this :
    <style id="jLabelNotes">
            <imageIcon id="iconNotes" path="images/note.png" />
            <property key="Label.icon" value="iconNotes" />              
    </style>
    <bind style="defaultLabel" type="name" key="jLabelNotes" />But nothing append.
    Thanks.

    Try Sound Menu

  • How to Use different icons for JTree in the same level

    Hi guys, i come cross a problem with JTree. The module need a JTree which need to represent items in the same level using different icons. For example:
    [Icon for Root]Root
    |
    |_____________[Icon for Table] TABLES
    |
    |_____________[Icon for Index] INDEXS
    |
    |_____________[Icon for Views] VIEWS
    As i know, the default behavior for JTree is using the same icon for all leaves and
    the same icon for all node that has children. How can i achieve that?
    Thansk a lot!

    subclass DefaultTreeCellRenderer. if you overwrite the method below, then you can set the icon to whatever you want....!
        public Component getTreeCellRendererComponent(JTree tree, Object value,
                                    boolean sel,
                                    boolean expanded,
                                    boolean leaf, int row,
                                    boolean hasFocus) {
         String         stringValue = tree.convertValueToText(value, sel,
                               expanded, leaf, row, hasFocus);
            this.tree = tree;
         this.hasFocus = hasFocus;
         setText(stringValue);
         if(sel)
             setForeground(getTextSelectionColor());
         else
             setForeground(getTextNonSelectionColor());
         // There needs to be a way to specify disabled icons.
         if (!tree.isEnabled()) {
             setEnabled(false);
             if (leaf) {
              setDisabledIcon(getLeafIcon());
             } else if (expanded) {
              setDisabledIcon(getOpenIcon());
             } else {
              setDisabledIcon(getClosedIcon());
         else {
             setEnabled(true);
             if (leaf) {
              setIcon(getLeafIcon());
             } else if (expanded) {
              setIcon(getOpenIcon());
             } else {
              setIcon(getClosedIcon());
            setComponentOrientation(tree.getComponentOrientation());
         selected = sel;
         return this;
        }

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

  • Jtable: set different icons for  selection/deselection

    Hai,
    I have designed a Jtable, I would like to set a column that has to show different icons when selected/deselected that row. To be specific when you click for the first time, it has to show ICON1 and if you click again it has to show ICON2. Any ideas ???
    Thanks,
    Bala.

    I haven't tried this - so take it with a grain of salt. In your table model, you can define the getColumnClass for the column as ImageIcon.class. In the getValue for that column, you would return the icon.
    In order to get the cell to act like a button .. so you can alternate between the icons ... is a little more complex. There is a book on Advanced Swing by Kim Topley that gets into making cells act like buttons. This part works because I have tried it -- but I wasn't displaying icons.
    good luck!

  • How to set different font for numbers in headings and TOCs

    Hi,
    I've noticed some people use a different font for numbers in headings and TOCs to get some extra magic. Is there any way to automate such use of fonts in the paragraph styles?
    Oh, and any suggestions on what fonts would be good for numbers?
    Thanks!

    I was merely continuing on the original theme -- any digit in any character style. It was only later revealed that (a) the OP needed old style figures, and (b) those were available in his font from the start.
    The negative lookahead is the answer to his question (copied in full now)
    Based on the above InDesignSecrets tutorial, does anyone know what to do if some of the numbers end with a dot or a comma?
    Like the Norwegian date format: 13. mai 2009
    Or the Norwegian way of pricing items: 2900,-
    and my example shows it can be done, but with an added caveat. If digits are to be set in red, using the exceptions the OP asks for, my example sentence will come out as
    "Think of a number between 1 to 10, but don't use 9."
    rather than the (here) intended
    "Think of a number between 1 to 10, but don't use 9."

Maybe you are looking for

  • Data Modeler How to display the "relationship name" vertically

    Is there any way to display the relationship name vertically. In Designer, it used to be like that.

  • ABAP query using PSJ

    Is there a way to get the company code project profile and the co amount using an Query . something similar to CJI3 but with the comapny code and project profile. Or if i have to use ABAP.

  • Image Button. How to mark it on slide?

    Hello! I wonder how to mark, put attention on the Image Button? I'm working on a project, where I use custom navigation pannel with Image Buttons. Some slides changes without navigation. And some slides paused till button pushed. I would like to pay

  • Cant change main enail address

    it is not letting me change my main email address as it says the one im changing it to is my rescue address but i have changed my rescue address to a different ine now.. v annoying as the existing main email is not in use anymore !

  • Access network path from within servlet

    I'm trying to copy some files from a network path from within a servlet. I realize that I cannot use drive letter mappings as they are profile specific. Instead I'm trying to use the unc path. I'm getting the following error when I read the error inp