JTree cell renderer: how to fill whole row?

hi,
i'm trying to make a tree cell renderer that renders at default height, but fills the horizontal width of the tree (e.g. with a JLabel with a custom background color). I'm working on the theory that in order to do this you need to change the preferred size of the component used to stamp the image at render time.
The problem is that the preferred width then needs to be set to a value that depends on the context of the particular node (e.g. a deeply nested child node will be further to the right than the root node).
I can't seem to find a method to say where the rendering starts though - does anyone know a way?
(also if not then would setting the width to some astronimcal value break anything?)
thanks,
asjf

Try this one, it will higlight the background and foreground colors of entire rows.
Oscar
     class TableRenderer
          extends DefaultTableCellRenderer
          implements ListCellRenderer
          private boolean focused = true;
          private JLabel renderer;
          public TableRenderer()
               super();
               renderer = new JLabel();
               renderer.setOpaque(true);
          public Component getListCellRendererComponent(
               JList list,
               Object value,
               int index,
               boolean isSelected,
               boolean cellHasFocus)
               return renderer;
          public Component getTableCellRendererComponent(
               JTable table,
               Object value,
               boolean isSelected,
               boolean hasFocus,
               int row,
               int column)
               renderer =
                    (JLabel) super.getTableCellRendererComponent(
                         table,
                         value,
                         isSelected,
                         hasFocus,
                         row,
                         column);
               /* Make the Labels border empty and indented */
               setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
               /* This is used to create alternate row colors */
               Color bgColor = Color.white;
               if (row % 2 == 0)
                    bgColor = new Color(237, 243, 254);
               /* if the table has focus and the row is selected use these colors */
               if (table.hasFocus() && table.getSelectedRow() == row)
                    table.setSelectionForeground(Color.WHITE);
                    table.setSelectionBackground(new Color(101, 137, 178));
               /* if the table has not the focus but the row is selected use these colors */
               else if (
                    table.hasFocus() == false && table.getSelectedRow() == row)
                    table.setSelectionBackground(new Color(196, 196, 194));
               /* if not use the standard color */
               else
                    renderer.setBackground(bgColor);
                    table.setSelectionForeground(SystemColor.textText);
               if (value instanceof ColorData)
                    ColorData cvalue = (ColorData) value;
                    setForeground(cvalue.color);
                    setText(cvalue.data.toString());
                            /* Set the Labels value */
               setText(String.valueOf(value));
               return renderer;
     }

Similar Messages

  • How to make JTree cell renderer respect layout?

    Hi,
    In the JTree tutorial, the first example TreeDemo shows a simple tree.
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
    If you grab the frame and make it really thin, you get a horizontal scroll bar in the top pane.
    How can I make it so that the tree cells just draw "..." at the end of the string if there is not enough space?
    I know the tree cell renderer uses JLabel, but they never seem to show "...", which is one of the best features of a JLabel. Any help is greatly appreciated!

    Hi,
    I got it working, but I also discovered a Java bug that ruins all this effort!
    Calculating the node's position & width:
    - When child nodes are indented, there is an "L" shaped line drawn... the space to the left of the line's vertical bar is the "leftChildIndent", and the space to the right is the "rightChildIndent". So you add both to get the whole indent.
    - I use label.getPreferredSize().width to figure out the node width, since that includes the icon width, the icon-text gap, and the font metrics.
    Example program:
    - This program models how I want it to look... Always expanded and automatic "..." when the scroll pane is not big enough.
    Bug found:
    - There is a runnable example below. Just run it and after a couple seconds, move the split pane to the right.
    - I use a timer to add a new node every 1 second. The new nodes get stuck being too small, and the original nodes don't have this problem.
    // =====================================================
    * Adaptation of TreeDemo to allow for tree nodes that show "..."
    * when there is not enough space to display the whole label.
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTree;
    import javax.swing.Timer;
    import javax.swing.UIManager;
    import javax.swing.event.TreeExpansionEvent;
    import javax.swing.event.TreeWillExpandListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.ExpandVetoException;
    import javax.swing.tree.TreeCellRenderer;
    import javax.swing.tree.TreeSelectionModel;
    public class TreeDemo extends JPanel {
        private JTree tree;
        protected class EllipsesTreeCellRenderer implements TreeCellRenderer {
            Integer leftIndent = (Integer) UIManager.get("Tree.leftChildIndent");
            Integer rightIndent = (Integer) UIManager.get("Tree.rightChildIndent");
            int indent = leftIndent.intValue() + rightIndent.intValue();
            JLabel label = new JLabel();
            DefaultTreeCellRenderer r = new DefaultTreeCellRenderer();
            public Component getTreeCellRendererComponent(JTree tree, Object value,
                    boolean selected, boolean expanded, boolean leaf, int row,
                    boolean hasFocus) {
                label.setText("why hello there why hello there why hello there");
                if (selected) {
                    label.setForeground(r.getTextSelectionColor());
                    label.setBackground(r.getBackgroundSelectionColor());
                } else {
                    label.setForeground(r.getTextNonSelectionColor());
                    label.setBackground(r.getBackgroundNonSelectionColor());
                if (leaf) {
                    label.setIcon(r.getLeafIcon());
                } else if (expanded) {
                    label.setIcon(r.getOpenIcon());
                } else {
                    label.setIcon(r.getClosedIcon());
                label.setComponentOrientation(tree.getComponentOrientation());
                int labelWidth = label.getPreferredSize().width;
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                int level = node.getLevel();
                if (!tree.isRootVisible()) {
                    --level;
                int indentWidth = indent * level;
                int rendererWidth = labelWidth + indentWidth;
                // This is zero the first few times getTreeCellRenderer is called
                // because the tree is not yet visible.
                int maxWidth = (int) tree.getVisibleRect().getWidth();
                if (maxWidth > 0) {
                    if (rendererWidth > maxWidth) {
                        // figure out how much space "..." will consume.
                        label.setText(label.getText() + "...");
                        maxWidth = maxWidth
                                - (label.getPreferredSize().width - labelWidth);
                        label.setText(label.getText());
                        // chop off characters until "..." fits in the visible
                        // portion.
                        if (maxWidth > 0) {
                            while (rendererWidth > maxWidth
                                    && label.getText().length() > 1) {
                                label.setText(label.getText().substring(0,
                                        label.getText().length() - 2));
                                rendererWidth = indentWidth
                                        + label.getPreferredSize().width;
                            label.setText(label.getText() + "...");
                return label;
        public TreeDemo() {
            super(new GridLayout(1, 0));
            //Create the nodes.
            final DefaultMutableTreeNode top = new DefaultMutableTreeNode("");
            createNodes(top);
            //Create a tree that allows one selection at a time.
            tree = new JTree(top);
            tree.getSelectionModel().setSelectionMode(
                    TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.setCellRenderer(new EllipsesTreeCellRenderer());
            tree.addTreeWillExpandListener(new TreeWillExpandListener() {
                public void treeWillExpand(TreeExpansionEvent event) {
                public void treeWillCollapse(TreeExpansionEvent event)
                        throws ExpandVetoException {
                    throw new ExpandVetoException(event);
            for (int i = tree.getRowCount(); i >= 0; i--) {
                tree.expandRow(i);
            //Create the scroll pane and add the tree to it.
            JScrollPane treeView = new JScrollPane(tree);
            //Add the scroll panes to a split pane.
            JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
            splitPane.setTopComponent(treeView);
            splitPane.setBottomComponent(new JLabel(""));
            Dimension minimumSize = new Dimension(0, 0);
            treeView.setMinimumSize(minimumSize);
            splitPane.setDividerLocation(200); //XXX: ignored in some releases
            //of Swing. bug 4101306
            //workaround for bug 4101306:
            //treeView.setPreferredSize(new Dimension(100, 100));
            // Makes tree nodes appear cut-off initially.
            splitPane.setPreferredSize(new Dimension(500, 300));
            //Add the split pane to this panel.
            add(splitPane);
            // Adds a new node every 1 second
            Timer timer = new Timer(1000, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
                    DefaultMutableTreeNode child = new DefaultMutableTreeNode("");
                    model.insertNodeInto(child, top, 0);
                    for (int i = tree.getRowCount(); i >= 0; i--) {
                        tree.expandRow(i);
            timer.start();
        private void createNodes(DefaultMutableTreeNode top) {
            DefaultMutableTreeNode category = null;
            DefaultMutableTreeNode book = null;
            category = new DefaultMutableTreeNode("");
            top.add(category);
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
            category.add(new DefaultMutableTreeNode(""));
         * Create the GUI and show it. For thread safety, this method should be
         * invoked from the event-dispatching thread.
        private static void createAndShowGUI() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
                System.err.println("Couldn't use system look and feel.");
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("TreeDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            TreeDemo newContentPane = new TreeDemo();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }

  • Custom Jtree Cell Renderer goes to infinite loopp...any suggestion???

    Hey ...thanks for you help before....
    Another problem..
    My Jtree works fine with default Cell Renderer .. but goes to infinite
    loop with CustomDefaultRenderer after few minutes...
    Any suggestions....
        public DynamicTree() {
            super(new GridLayout(1,0));
            rootNode = new DefaultMutableTreeNode("POSTINGS & SEARCHES");
            treeModel = new DefaultTreeModel(rootNode);
            treeModel.addTreeModelListener(new MyTreeModelListener());
            tree = new JTree(treeModel);
            tree.setEditable(false);
            tree.getSelectionModel().setSelectionMode
                    (TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.setShowsRootHandles(true);
      //      tree.addMouseListener(ml);
      //      tree.addKeyListener(kl);
            JScrollPane scrollPane = new JScrollPane(tree);
            add(scrollPane);
            //          tree.setCellRenderer();
            tree.addTreeSelectionListener(new TreeSelectionListener(){
                public void valueChanged(TreeSelectionEvent evt){
                    System.out.println("Tree's lead selection path is " +
                            tree.getLeadSelectionPath());
            tree.setCellRenderer( new CustomDefaultRenderer());              
    public class CustomDefaultRenderer extends DefaultTreeCellRenderer {
        String suffix = null ;
        String prefix = null ;
        boolean expired = false;
        boolean matched = false ;
        PostingHandler pHandler = new PostingHandler();
        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);
            suffix = (String)value.toString() ;
            try {
                prefix = value.toString().substring(0,value.toString().indexOf(":") + 1);
                suffix = suffix.substring(suffix.indexOf(":")+1,suffix.length());
                System.out.println("Prefix:"+prefix +"\tSufix :"+suffix);
            }catch (Exception e){System.out.println("Nothing to index yet" + e);}
            //    value = (Object)suffix;
            if(pHandler.newPostingsMatch.contains(prefix)) {
         //            if(hasFocus){pHandler.removePostingMatch(prefix);}               
                         setBackgroundNonSelectionColor(Color.CYAN);
            }else
                setBackgroundNonSelectionColor(Color.WHITE);
            System.out.println("Other <>values:\tValue" + value.toString() + "\tSEL:"+sel +"\tExpanded:" + "\tLEAF:"+leaf +
                    "\tRow:" +row + "\tfocus:"+hasFocus );
            return this;
        public void paintComponent(Graphics g){
            System.out.println("Paint is called");
            //g.drawLine(0, 0, 100, 100);
            if(expired){
                g.drawLine(22, 11, 100,11);
            g.drawString(suffix, 22,15);
            validate();
            repaint();
    }

    Figured it out right after this post :)
    I had to do the following in my cellrenderer
    setBackgroundNonSelectionColor(new Color(0, 0, 0, 0));As a parameter I sent a color object with a alpha level of 0 (completly transparent)...

  • TableSorter + custom cell renderer: how to get DISPLAYED value?

    Hi!
    I have a JTable with a custom cell renderer. This renderer translates numerical codes, which are stored in the table model, into textual names. E.g. the table model stores country codes, the renderer displays the name of the country.
    Now, having a reference on the JTable, how can I get the DISPLAYED value, i.e. the country name? Is there some method like ....getRenderer().getText()?
    Thanx,
    Thilo

    Well, a renderer can be anything. It may be rendering an image not text so you can't assume a method like getText(). However, since you know the component being used to render the cell you should be able to do something like:
    TableCellRenderer renderer = table.getCellRenderer(row, column);
    Component component = table.prepareRenderer(renderer, row, column);
    Now you can cast the component and use get text.
    Another option would be to store a custom class on the table cell. This class would contain both the code and value. The toString() method would return the value. Whenever you want the code you would use the table.getValueAt(...) method and then use the classes getCode() method. Using this approach you would not need a custom renderer. This thread shows how you can use this approach using a JComboBox, but the concept is the same for JTable as well:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=417832

  • JList or JTree Cell Renderer

    hi. im doing a scheduler application
    wherein a list is displayed and when user post
    a scheduled activity, a textbox will be painted
    on top of the list, so that you could do away with
    overlapping schedules(2 or more schedule with
    the same time interval/s). Much like as that of
    the MS Outlook calendar.
    Can anyone post a snippet of the code of the
    cell renderer? im having a hard time studying
    cell rendering.
    thank you very much.

    Pls i badly nedd your help. somebody knowledgable on this?

  • JTree Cell Renderer Default

    Hi all,
    I am trying to set up an option that will allow a user to change the JTree Icon image to their prefered choice, I have a number of different images that changes when I select on the JMenuItem selection, as I am calling the ActionListener to another class called Renderer(), like:
    tree.setCellRenderer(new Renderer());
    But what I am trying to do is to try to allow the user to select the java default icons, can anybody show me how this is done. Its being annoying me for ages.
    thanks all

    Hi all,
    I am trying to set up an option that will allow a
    user to change the JTree Icon image to their prefered
    choice, I have a number of different images that
    changes when I select on the JMenuItem selection, as
    I am calling the ActionListener to another class
    called Renderer(), like:
    tree.setCellRenderer(new Renderer());
    But what I am trying to do is to try to allow the
    user to select the java default icons, can anybody
    show me how this is done. Its being annoying me for
    ages.
    thanks allThis information can be retrieved from the UIDefaults in the UIManager. The keys are:
    Tree.closedIcon
    Tree.collapsedIcon
    Tree.drawsFocusBorderAroundIcon
    Tree.expandedIcon
    Tree.leafIcon
    Tree.openIcon
    To retrieve the Icon, something like the following should work:
    Icon closedIcon = UIManager.getDefaults().getIcon("Tree.closedIcon");Jim S.

  • How can I apply row numbers and column litteral to identify the cells?, How can I apply row numbers and column litteral to identify the cells?

    I news identici row and column in numbers over and left as in Excel. How can I do?

    Hi Roanto,
    Welcome to Apple Support Communities.
    We're all feeling out way around in this newly designed environment, but I think I've discovered that the iWork applications for iPad are still in a community separate from those for the Mac versions of the iWork appplications.
    Seeing as you question is about Numbers for iPad, you might find it better served in the https://discussions.apple.com/community/ipad/iwork_for_ipad>Numbers for iPad Community area. The link will take you to the front page of that community.
    Regards,
    Barry
    PS: You might also consider rewriting your question. I'm having some difficulty deternmining exactly what you want to accomplish.
    B

  • JTree Cell Renderer Problem

    Hi can someone help me please??
    I've created a JTree with a custom TreeUI which paints the JTree's backround with gradient paint.
    The problem i'm having is that i want to make the background color of the treecells transparent, no color at all. In my custom TreeCellRenderer it works fine setting the foreground color and everything, but not the background...
    Any clues anyone?

    Figured it out right after this post :)
    I had to do the following in my cellrenderer
    setBackgroundNonSelectionColor(new Color(0, 0, 0, 0));As a parameter I sent a color object with a alpha level of 0 (completly transparent)...

  • JTree cell rendering

    All my tree nodes has an icon on the left and text on the right
    Just for a node or two, I need to put extra text on the right of the label text but in different color. What's the best way to do that?
    Would I have to change my renderer to not inherit DefaultTreeCellRenderer and inherit JPanel with TreeCellRenderer?
    Can I do it overwriting a paint function and check for that instance?
    Need a little example of doing extra work for a particular node that involves rendering in different colors...
    Thanks
    Abraham Khalil

    have you seen the demo tree renderer code here?
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
    as long as you have some way of telling when you need to render differently then you can either pass back the default renderer's component (ie call the super classes method) or pass back a privately owned one.
    you could either use JLabels support of HTML for rendering the text in a different color, or maintain two instances of a JLabel on a JPanel and use that as the stamp
    asjf

  • Select whole row in a JTable

    I would like to know how I can fix so that when a user clicks a cell in my JTable the whole row gets selected. Not with the clicked cell as white and the rest of the row in blue, but with the whole row in blue. I would also like to stop the cell from beeing edited. The third thing I wonder is how I can hide the grid between the cells, and make it look like a list??
    Thanks for replies!

    Thanks for the help!
    I managed to get the frame around the selected cell also. Did it by extending the DefaultTableCellRenderer. Found some more help here:
    http://forum.java.sun.com/thread.jsp?thread=447758&forum=57&message=2028189

  • JTree custom cell renderer question

    When using a custom cell renderer is their anyway to tell the offset of the current node?
    For example if you have a tree with the parent node "Parent" that has a few children nodes it will look something like this:
    Parent
    |----Child 1
    |----Child 2
    |----Child 3
    So the parent would have an offset of zero. I want to know how to get the childrens offset? If this is possible?
    What I am trying to accomplish:
    I have a JTree as a scrollpane rowHeader. While the main body of the scrollpane is a JTable. I need the tree's nodes to fill the entire width so that it looks like part of the table. I figure the row header width - current node offset should be the width that I will need each node to be. Any help is welcome. Thanks.

    the renderer tells you the row, the tree can get you a treepath for a row
    TreePath getPathForRow(int row)
    That can tell you the depth of the node.

  • JTable: Custom cell renderer on T(row, col)

    Sorry if this was posted before, but the whole Search function doesn't seem to work these days (hasn't been working for a week now). Anyways:
    I know how to create custom cell renderers. My problem lies with which cells I want to apply that cell renderer to. It seems I am limited in setting a cell renderer to a whole column, which I don't want.
    For instance, I'd like to apply cell renderer R1 to (0,0) but not to (1,0) and not to (3,0). Instead I want cell renderer R2 on (2,0) and (3,0).
    Example of my table:
    |--icon--|--filename--|--extension--|
    |   R1   |  file1.txt |     txt     |
    |   R2   |  img1.jpg  |     jpg     |
    |   R1   |  file2.txt |     txt     |
    |   R2   |  img2.jpg  |     jpg     |
    |-----------------------------------|Is there any possibility this can be achieved? I am probably overlooking some method or class, but I don't know which. Some pointers or clues in the right directions are appreciated.
    Thanks

    Camickr, again you've been a great help. Works great, but a NullPointerException is being thrown and I can't find out what points to a null object.
    Code is this:
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (getValueAt(row, 3).equals("jpg") && column == 0) {
                return new IconCellRenderer(Klue.iconAdd);
            } else {
                return super.getCellRenderer(row, column);
        }Solution is catching the NullPointerException in this method, but I'd rather have an if statement checking for it. But what to check? Any ideas?

  • Coloring entire row ??? (TableColumn) (cell rendering)

    Hi,
    I know this question has been posted a few times but i just couldn't make it work.. i have attached my app below. the idea is to paint the whole row to red if value[row,0] = '*' but the problem here is that only that particular row and column i.e. aRow and aColumn indicated in the cell renderer class is painted red .. i want the whole row to be red not only that particular column and row.. i can get the aRow and aTable from the renderer class but can't figure out how to use these values to paint the whole row for the table RegLocationsTableModel2...... please shed some lights on this.....
    loadhandler.java
    =============
    int vcolIndex=0; //for checking '*' value
    TableColumn col = screen.regLocationsTable.getColumnModel().getColumn(vColIndex);
    col.setCellRenderer(new RenderRedGreen());
    ( (RegLocationsTableModel2) screen.regLocationsTable.getModel()).
    addPartnerProRecord(partner);
    ( (RegLocationsTableModel2) screen.regLocationsTable.getModel()).
    fireTableDataChanged();
    cell renderer class:
    ===============
    final class RenderRedGreen extends DefaultTableCellRenderer {
    RenderRedGreen () {
    setHorizontalAlignment(SwingConstants.RIGHT);
    public Component getTableCellRendererComponent(JTable aTable,
    Object aNumberValue,
    boolean aIsSelected,
    boolean aHasFocus,
    int aRow, int aColumn) {
    if (aNumberValue == null) return this;
    Component renderer = super.getTableCellRendererComponent(aTable,
    aNumberValue,
    aIsSelected,
    aHasFocus,
    aRow, aColumn);
    System.out.println("RenderRedGreen.java::aTable=" + aTable);
    System.out.println("RenderRedGreen.java::aRow=" + aRow); // how to use these values????
    if (aNumberValue.equals("*"))
    System.out.println("RenderRedGreen.java::aNumberValu is *=");
    renderer.setBackground(Color.red);
    else {
    renderer.setBackground(Color.white);
    return this;
    thanx very much....
    tamoooo

    even after changing that if(..) statement, only the first column/cell of the row that has '*' value is coloured to red... other columns of the row basically remains as white..
    as far as i understand correctly the cell rendering, in my case, the loadhandler.java calls the cell renderer class (RenderRedGreen.java) with vColIndex=0... i.e. checking the 0th column of the row.. if the value of the first cell is '*' then the background OF THE CELL is set to red otherwise the background of the cell is set to white.. and all the while, the check is only been done on the 0th column of each row... so basically no coloring will be done on the other rows.. (???)
    i think that somehow since aRow of aTable indicates the row for whose the 0th column is '*' and is the row whose entire column is to be colored.. somehow it has to be rendered from within the render class (RenderRedGreen.java).. any suggestions??? i think some of us has already done entire row coloring.. need some insight into this..

  • How to fill column value of a matrix with specific color when there is no value in that specific cell?

    Hi All,
    I need to create a 5/5  matrix in SSRS report. The data will be :
    Col_Side   Col_Header   Col_data
    1                  1                1
    1                  1                 1
    1                  2                1
    1                  5                1
    1                  5                1
    1                  5                1
    2                  3                1
    2                  5                1
    3                  1                2
    3                  1                2
    3                  1                2
    4                   2               1
    4                   4               1
    5                   1               1
    5                   1               1
    5                   5               1
    So, the matrix column will be Col_Header and matrix row will be Col_Side and count(Col_data) will be on the data.
    Finally, it will create a 5 by 5 matrix with Count(Col_data) as its data for each combinations. If there is no combination (for ex: in the above data we do not have no combination of (1,3) , (1,4) , (2,1) etc..) then the matrix will be filling that corresponding
    cell with zero.
    Here I need to fill the cells with some colors based on some criteria.
    I need to fill (5,3), (5,4), (5,5) combination with "Red" color.  Like this , I need to give different colors in each of the cells. Here, (5,5) combination will be having 1 in its cell.  (5,4) and (5,3) will be having zero in its corresponding
    cells. I 'm trying to fill all the 3 cells with "Red" color. But, I am able to fill only (5,5) with "Red" color. Since the other 2 cells (5,3) and (5,4), has zero in their cells, it will not fill the cells with "Red" color. 
    How can I fill those two cells (5,3) and (5,4) with red color?
    I know this is very vague. I have no option to give the picture here..
    Please suggest

    Hi Julie,
    According to your description, there is a 5/5 matrix with three fields: Col_Side, Col_Header, Col_data. You drag Col_Side field to Rows, Col_Header to Columns and Col_data to Data, then filling blank cells with zero using expression. Now you want to fill 
    (5,3), (5,4), (5,5) cells with red color using expression, but it has no effect on cells (5,3) and (5,4).
    According to my test, the expression has on effect on cells (5,3) and (5,4) since there is no corresponding data and the cells are blank. As a workaround, we can insert data for cells (5,3) and (5,4) in dataset, then use expression by following steps:
    In the dataset, insert two sets of data (5,3,0), (5,4,0).
    Right-click the cell of data, click Text Box Properties.
    Click Fill in left pane, click (fx) button, then type the expression like below, then click OK.
    =iif(Fields!Col_Side.Value=5 and Fields!Col_Header.Value >=3 ,"red","white" )
    The following screenshot is for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu

  • How to fill an empty cell with the value above

    Hello,
    Please help me on the following issue related to BEx query and it's output in BEx analyzer as well as on Web.
    I am trying to modify a query output where the empty cells are to be filled with the value in the above cell.
    e.g. there is a column for transaction number, and this transaction number is the same for three rows, so it turns out to be two empty cells and only appears as if the transaction number applies to the first row only.
    not sure how to paste screenshot or attach document but would love to provide more information if the above isn't suffice.
    Please advise on what and where to modify in BEx designer.
    Thank you for your help!

    Thanks a lot...yes, now it works in BEx Analyzer but for some reason doesn't work in the Web view.
    Any ideas why is that?
    Thanks again for your prompt help.
    Edited by: One Idea on Jan 15, 2009 12:17 AM

Maybe you are looking for

  • Reference to FLVPlayback Skin object

    So I have a problem with the FLVPlayback. I'm using a customized version of the SteelOverPlaySeekMute skin, and it works very well. The only problem is, that Macromedia coded the FLVPlayback.skinAutoHide poorly, in that it only hides when an onRollOu

  • Anonymous login in sender,reciever file adapter

    hi all xi's i dont know what is the need of anonymous login option in sender,reciever file adapter and the other thing is if i use check anonymous login there is no option for specifing username,pwd,ftp server ip. early anser will be appreciated. bye

  • Email uploaded PDF document

    Hi, I want to email PDF  document uploaded using FileUpload UI element as attachment. I have seen many posts on this, but not found solution yet. One workaround suggested is storing uploaded document on server and then sending the document by reading

  • How to see what version of Cisco Jabber end users have installed

    We are running CUCM / CUP 10.5.1.   Where would I be able to see which versions of Jabber are in our environment?   I want to upgrade everyone to Jabber for Windows 10.5, but first I would like some visibility into our current environment.

  • Using Motorola red SLVR (charity phone) with OS X

    Hi everyone. I'm considering getting the new Motorola red SLVR on the UK's T-Mobile network. This is the phone that makes a donation to AIDS in Africa and I don't think it has any other model number (such as L7). Questions: 1) is it going to sync nic